Quantum Machine Learning – When Quantum Physics And Machine Learning Meet

Tram Ho

The basic properties of Quantum Mechanic

Quantum mechanics (QM; also known as quantum physics, quantum theory, the wave mechanical model and matrix mechanics), including quantum field theory, is a fundamental theory in physics describing the properties of nature on an atomic scale.

Translation: Quantum mechanics, including quantum field theory, is a cornerstone of physics that describes the properties (properties) of nature at the atomic level.

The principles of classical mechanics applied to the macroscopic world no longer accurately reflect the microscopic and subatomic microscopic activity. Quantum mechanics says that energy (the energy that constitutes the universe) is a material form, so it can be measured, measured, quantified and divided into units.


Large objects such as a planet or as small as a proton all have a property called spin.

Spin is the amount of rotation that an object has, considering its mass and shape. This is also known as the momentum moment of an object. Spin is a purely quantum concept, with no correspondence in classical mechanics.

The concept of spin was later shown to be in conflict with relativity. However, no matter how the source generates spin, the spins of all the particles that make up the physical world, such as electrons and quarks, are zero and equal to ħ / 2 (ħ is a plank constant). , referred to as 1/2. Particles such as photons have a spin of 1 … Thus, spin is an intrinsic feature of the particle, which is inherently the same as its characteristic mass and charge. If an electron has no spin, it is no longer an electron.

Quantum superposition and Qubit

Quantum superposition (or quantum superposition, quantum layering) is the application of the principle of superposition to quantum mechanics. The principle of superposition is the addition of the vectors to the wave vectors in the interference. In quantum mechanics, wave function vectors, or state vectors are added.

Specifically, quantum superposition can be stated as “if a quantum system can be detected in one of two states, A and B with different properties, it can also be detected at their combined states, aA + bB, where a and b are any numbers ”.

This is applied to quantum computers by creating quantum bits (quantum bits), called qubits for short. Quantum computer inventors use a particle as a qubit, and the spin state up or down corresponds to the state of the qubit.

Unlike a transistor-based digital computer that requires encoding data into binary digits, each number is assigned to one of two states of 0 or 1, quantum computation using bits. The quantum is in the overlapping state for calculation. This means that a quantum bit can have a value of 0 and 1 at the same time, ie the quantum superposition of the qubit occurs.

To explain this, imagine that a coin is tossing. Before it lands on the front or the back, it will spin through the air at an extremely fast speed. And when it’s spinning like that, at a certain point you determine the face of the coin, it will have both states, tails and heads.

Thus, if a computer has 2 qubits, at one point it will be 2 2 2 ^ 2 2 2 = 4 states, 3 qubits will be available 2 3 2 ^ 3 2 3 = 8 states, N N N qubit will have 2 N 2 ^ N 2 N states of the qubit simultaneously. This means that quantum computer N N N qubit will have equal to the power of 2 N 2 ^ N 2 N computers running in parallel . This explains why quantum computers are capable of calculating extremely fast compared to conventional computers.

Theoretically, a computer with lots of qubits is capable of handling an extremely large number of tasks such as arithmetic operations or performing an extremely large database search in a much faster time than computers. usually, common, normal.

Quantum entanglement

Quantum entanglement is a phenomenon at the particle level that scientists have not explained to date. It is the pairing and interaction of two particles in the universe completely independent of the distance between them. That is, if you have one photon at one end of the universe and another photon has a quantum entanglement with it, but at the other end of the universe, if you affect one particle, the other particle will be affected. This interaction is much faster than light and completely absolute. In other words: it does not depend on the distance between the two seeds.

The difference of qubits from the classical bits is not only in the continuous variation of value through quantum superposition, but also in the fact that many qubits can exist and relate to each other through the phenomenon of tangles quantum . This entanglement can occur at macro distances between qubits, allowing them to represent multiple overlaps of multiple character sequences (for example, overlaps 01010 and 11111). This “quantum parallel” property is the basic strength of quantum computers.

Quantum machine learning

Understand the concept of quantum computing in 1 minute

Now you may be wondering: “What is quantum algorithm?” . It is also simply a sequence of commands like any normal algorithm. In conventional computers we use classic gates like OR, AND, NOT. But what makes quantum computing different from conventional operations is that it uses quantum gates , which works on qubits instead of bits. So quantum algorithms’ input is made from qubits, as simple as if you have n qubits and you also have 2 n 2 ^ n 2 n states, with 300 qubits you have 2 300 2 ^ {300} 2 3 0 0 states occur at the same time, 2 300 2 ^ {300} 2 3 0 0 is the same atomic number in the entire universe ^^

A typical example in real life that applies quantum computing is Google’s superconductor processor that uses 54 qubits to perform the 200-second math operation that conventional computers with current algorithms need. 10,000 years to solve.

What is quantum machine learning?

Quantum machine learning is a new field of research combining quantum physics and machine learning. With the aim of developing quantum algorithms from data to improve the existing methods in machine learning.

QML has made brilliant innovations mathematically, since mathematics is the core of quantum algorithms. But the reality is that these innovations have not been fully exploited and the conventional ML algorithms used in Artificial Neural Networks (ANNs) still prove useful when running on traditional computers. But according to the new trend of the era of 4.0 when Big Data is leading and increasing business processing requirements of enterprises, QML will gradually replace traditional ML. In addition, majors like Quantum Computer Science and Quantum Information Science will make tremendous changes to AI in the next 10 years and set the stage for a new industry era 5.0.

So how will QML replace and support traditional ML? There are 2 main directions:

  • Quantum versions of ML algorithms: (1) use quantum versions in finding eigenvalues ​​and eigenvectors of large matrices, (2) search for nearest neighbors in quantum computers, (3) quantitative methods In improving experiments on Higgs boston particles, it creates a framework for understanding particles and basic interactions in nature, or (4) Quantum algorithms to solve linear problems in ML. .
  • Classical ML to analyze quantum systems: (1) identify quantum change points, (2) binary classification of qubit states, (3) quantum coupling loss, and ( 4) reproduce observed values ​​in thermodynamics.

Quantum neural network

Quantum neural network (QNN) is a neural network model based on the basic principles of quantum physics such as qubit, superposition … and only using O ( log ( N ) ) O ( log (N)) O ( lo g ( N ) ) the variable parameter for input is N N N qubits.

Implementing QNNs is one of the important strides in AI and ML. The first steps are to simulate Perception in QNNs, or to simulate a quantum neutron. We can rely on many-worlds Interpretation to simulate neutrons. Many world interpretations suggest that there exist parallel universes around us with completely determined past and future. So what does this theory have to do with QNNs? We can understand simply that ANNs use a neural network to store different patterns but QNNs can use many neural networks at the same time to store many different patterns. It sounds quite abstract, isn’t it? You can imagine it as qubit exists 2 states are 0 and 1 at the same time (Superposition).

Hybrid quantum-classical

Throughout the lesson, you’ve learned the basics. Now, we will use TensorFlow Quantum to build a hybrid quantum network, we will use the net neural net to control a single qubit. The control will be optimized to accurately prepare qubits in states of 0 or 1, more specifically it will learn to control errors of a system we will simulate below:

First we will initialize a bit loop in a Controller Circuit

Building a simple network layout using keras (controller network):

Use tfq to connect to the controller circuit as a keras.Model :

Next apply a series of calculations to those inputs, to calculate:

Now encapsulate this calculation by using a tf.keras.Model :

Draw model:

This model has two inputs: The instructions for the controller and the output of the controller circuit

Build the command input values ​​and the desired output:

This is not all training data for this task. Each datapoint in the dataset also needs an input circuit, which we will talk more about in the next paragraph

The input-circuit below identifies the random error calculation that the model will learn to correct:


Next we will build the functions for the training process:

From the plot above you can see that the network process has learned how to overcome the system miscalculation.

We have just gone over a series of basic concepts about quantum machine learning, as well as discussed it. Although this is a relatively young technology, its potential is great in artificial intelligence, thank you for reading, see you in the next article. ?









Share the news now

Source : Viblo