Time: 1-2 Hours
Expected knowledge: Basic familiarity with Google Cloud is strongly encouraged. Some knowledge of machine learning and quantum circuits and algorithms is helpful
System requirements: Internet access, Python 3.6 or later
Expected knowledge: Basic familiarity with Google Cloud is strongly encouraged. Some knowledge of machine learning and quantum circuits and algorithms is helpful
System requirements: Internet access, Python 3.6 or later
>= 0.6.0
), it’s now possible to use the quantum machine learning spinoff of one of the world’s most well-known machine learning libraries with IonQ’s devices. Whether you’re struggling with barren plateaus, or doing full-fledged reinforcement learning, this guide can help you take the first step on the path of becoming a quantum machine learning (QML) expert.
Before you begin
You’ll need an account on the IonQ Quantum Cloud, and you’ll need to create an API key. We also have a guide about setting up and managing your API keys if you need some help. This guide assumes that you have followed these instructions and have saved your API key as a local environment variable namedIONQ_API_KEY
.
About Tensorflow Quantum
TensorFlow Quantum (TFQ) is part of TensorFlow, a popular library for prototyping, training and deploying machine learning models. TFQ’s quantum machine learning tools help users of a variety of skill levels prototype and build machine learning models that use a hybrid quantum-classical approach by combining the quantum computing tools and logic designed in Cirq, with TensorFlow APIs, and inbuilt quantum circuit simulators. The TensorFlow Quantum whitepaper and TensorFlow Quantum website provide more details on the motivation and philosophy behind the project, as well as full API documentation and example code for a variety of common ML application.Installing and Setting up TensorFlow Quantum
You can install TensorFlow Quantum from PyPI, the Python Package Index, usingpip
.
We recommend creating a requirements.txt file and then installing from that:
Note about Windows: Tensorflow Quantum must be built from source for Windows support. Alternatively, you can try running these inside WSL or a docker container.
Note about Python: We encourage doing this inside an environment management system like virtualenv or conda so as to avoid this fate, but do what makes the most sense for you.
Note about Python: We encourage doing this inside an environment management system like virtualenv or conda so as to avoid this fate, but do what makes the most sense for you.
venv
and install our above requirements in to it, run the following:
Running your first TensorFlow Quantum program
Here is an adaptation of TFQ’s Hello, many worlds tutorial, which uses the IonQ simulator backend to train a simple parameterized circuit. Run the following as a Python script or in a Jupyter notebook, and you’re off to the races:Licensing for TensorFlow Quantum and all code samples in this document are Apache 2.0.