ConceptAdvancedquantum machine learningLesson 5

Quantum Neural Networks

'Quantum neural network' is a common name for a layered parameterized-circuit model trained by gradients; it is linear in the quantum state, and its nonlinearity in the input comes from the encoding.

The term quantum neural network (QNN) is used in the literature for a variety of models, the most common today being the layered parameterised circuit: an encoding layer $S(x)$, then trainable layers $W(\theta)$ made of rotations and entangling gates, then the measurement of an observable $O$. The model's output is $$f_\theta(x)=\mathrm{Tr}\big[O\,W(\theta)\rho(x)W^\dagger(\theta)\big],\qquad \rho(x)=S(x)|0\rangle\langle0|S^\dagger(x).$$ Mitarai and colleagues (2018) studied this type under the name "quantum circuit learning", and Benedetti and colleagues (2019) reviewed parameterised circuits as machine learning models.

The analogy with neural networks is partial, and its limits must be understood. First, the model is linear in $\rho(x)$: there are no non-linear activation functions between layers, because unitary evolution is linear. The non-linearity in $x$ comes from the encoding map, where $x$ appears inside trigonometric functions, and from measurement and the classical processing after it. Second, unitary layers preserve the norm and lose no information, unlike classical layers, which may compress the data. Third, the output is an expectation value estimated from a finite number of shots, so it is a noisy estimate.

The expressivity of the model depends on how many times the input is encoded and on the layer structure. If $x$ is encoded once with a Pauli rotation, $f_\theta(x)$ is a first-degree trigonometric polynomial; repeating the encoding $L$ times raises the possible degree to $L$. Increasing the depth randomly, however, can hurt trainability: McClean and colleagues (2018) showed that the variance of the gradient in deep random circuits decreases exponentially with the number of qubits.

In the lab, this model corresponds to the variational classifier (VQC) experiment: encoding, then $R_Y$/$R_Z$ layers with CNOT, then $\langle Z_0\rangle$, converted to the probability of class 1 by $(1-\langle Z_0\rangle)/2$, and a binary cross-entropy loss. It is important to remember that successful training on small data does not prove superiority over a small classical neural network on the same problem.

In short, the name "neural network" refers to gradient-based training and the layered structure, not to a full mathematical similarity; in scientific writing it is more precise to say "a parameterised-circuit model" and to state the encoding and the observable used.

Mathematical formula

$$f_\theta(x)=\mathrm{Tr}\big[O\,W(\theta)\rho(x)W^{\dagger}(\theta)\big]$$

Worked example

Let us compute the model formula for $S(x)=R_X(x)$, $W(\theta)=R_Y(\theta)$, $O=Z$ on one qubit.

After $R_X(x)$ the Bloch vector is $(0,-\sin x,\cos x)$. The rotation $R_Y(\theta)$ rotates the $(x,z)$ components: $z'=\cos\theta\,z-\sin\theta\,r_x$, and $r_x=0$ here, so $$f_\theta(x)=\cos\theta\cos x.$$

This is a first-degree trigonometric polynomial in $x$, as the theory predicts. At $\theta=0$ and $x=\pi/3$: $f=0.5$, so $P(\text{class }1)=(1-0.5)/2=0.25$. This model cannot represent $\cos 2x$ for any $\theta$; that is why we need re-uploading.

Test your understanding

The quiz needs JavaScript.

Related topics

References

  1. K. Mitarai; M. Negoro; M. Kitagawa; K. Fujii (2018). Quantum circuit learning. Phys. Rev. A 98:032309 doi:10.1103/PhysRevA.98.032309
  2. Marcello Benedetti; Erika Lloyd; Stefan Sack; Mattia Fiorentini (2019). Parameterized quantum circuits as machine learning models. Quantum Sci. Technol. 4:043001 doi:10.1088/2058-9565/ab4eb5
  3. Maria Schuld; Alex Bocharov; Krysta M. Svore; Nathan Wiebe (2020). Circuit-centric quantum classifiers. Phys. Rev. A 101:032308 doi:10.1103/PhysRevA.101.032308