Join us

Quantum Artificial Intelligence


In this article we want to develop a neural network that can measure a simulated qubit and return the correct value between 0 or 1.

Initially, the qubit will generate errors, our goal is to train a neural network that creates the parameters for the qubit to fix these errors.

First, we need to define our quantum circuit using the using cirq library and install or import tensorflow.

So we have told python to allocate space in memory for our circuit, now we want to develop our neural network that will control it. We will not be too extravagant with our neural network, we will just have the input, a hidden layer of size 10 and an output of size 3.

The 3 outputs the network corresponds to the three parameters we already set.

After creating a controller and a quantum circuit and we need to connect them, to do this we will create inputs for both the controller and the circuit, starting with the circuit:

Then we need to create inputs for our commands:

Now we want to connect the two models, we will go about this by creating layers for both the neural network and the quantum circuit.

We connect the two models by creating a layer for the controller, another layer for the quantum circuit input and connecting them using a perimeter quantum circuit, which trains our quantum circuit.

Now that we have our model time to create our data as well as calibrate our circuit input.

To do that we will create two data points to map, our input values for our output.

To calibrate our circuit inputs we need to set our theater values to a random number, between 0 and 2*pi.

We also want to make sure we have two copies of the circuit so that we can create data values for both inputs.

And now we can train our model! You can see from the plot that our error is pretty low by the end — try changing the number of epochs to see what the minimum number of epochs is to still get good results.

When you run the command on your notebook, you will discover the error rate is low. This is a good thing but we still do not know for sure if the qubit is in the right state. So we want to check!

What if you wanted to add more data between 1 and 0? As we know qubits can be 1,0 both or in between the two.

Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN account now!


The Maths Geek 🤓

Mathematician | Software Engineer | Amazonian| Open Source | Blogger | Ban Killer Robots
User Popularity



Total Hits



Mentioned tools