Pattern Atlas

Extended Quantum Computing Patterns

Quantum Neural Network (QNN)

Aliases:

Tags:

© L. Stiliadou, J. Barzen, M. Beisel, F. Leymann, and B. Weder, Patterns for Quantum Machine Learning, in Proceedings of the 17th International Conference on Pervasive Patterns and Applications (PATTERNS), Xpert Publishing Services (XPS), 2025.

Intent

How to learn an unknown unitary operator using a quantum device?

Context

An unknown unitary operator needs to be learned from a training set containing the quantum inputs and the expected quantum outputs.

Forces

Identifying a unitary operator that is capable of mapping input data to their respective output is getting increasingly more difficult with the complexity and variety of the data. Determining such a mapping requires a lot of input data, and the training procedure requires significant computational power [Achiam et al., 2023]. However, this number can be reduced as outlined by the Quantum No-Free-Lunch Theorem since only obtaining a subset of the training samples as entangled quantum states is already beneficial [Mandl et al., 2023].

Solution

Figure 4 shows the training process of a QNN to learn an unknown unitary operator \(U\): To realize a corresponding quantum circuit, first, the input data are encoded to a quantum state \(\newcommand{\state}[1]{{\left| #1 \right>}} \state{x}\). Similarly to classical neural networks, quantum circuits realizing a QNN comprise various parameterized hidden layers \(V_i(\vec{θ})\) to approximate \(U\). The parameters \(\vec{θ}\) are iteratively adjusted by an optimizer, which minimizes a cost function until the quantum circuit produces approximately the expected outputs. The cost function uses the expected outputs and similarity measures, such as fidelity, to evaluate how closely the produced outputs \(\newcommand{\state}[1]{{\left| #1 \right>}} \state{\tilde{y}}\) match the expected ones \(\newcommand{\state}[1]{{\left| #1 \right>}} \state{y}\).

Solution Sketch

Result

The result is a set of parameters that configures the QNN to approximate the expected output of the unknown unitary operator. The quality of the approximation depends on the size of the training set, its linear structure, and the degree of entanglement [Mandl et al., 2024]. While entangled data provides benefits for the training of QNNs, a too high level of entanglement can lead to barren plateaus [Thanasilp et al., 2023b].

Examples

A special kind of QNNs are quantum convolutional neural networks, which are utilized for processing structured grid data, e.g., for image processing [Hur et al., 2022] [Wei et al., 2022]. It comprises four different types of layers: (i) First, state preparation layers are used to encode the classical input data. (ii) The convolutional layers enable the detection of spatial patterns within the input data. (iii) Pooling layers reduce some of the spatial dimensions to focus on the optimization of the most important features. (iv) Finally, fully connected layers are used to produce the final output of the quantum convolutional network.

Related Patterns

Quantum neural networks are a realization of the Variational Quantum Algorithm (VQA) pattern [Weigold et al., 2021b]. Different state preparation routines, such as Angle Encoding or Basis Encoding [Weigold et al., 2021a], can be utilized to encode the input data of the QNN. To integrate a QNN in existing applications, it can be provided as a Hybrid Module [Bühler et al., 2023].

Known Uses

Jeswal et al. [Jeswal and Chakraverty, 2019] and Vasuki et al. [Vasuki et al., 2023] provide surveys overviewing the various application areas of QNNs, ranging from prediction to pattern recognition problems. Kashif et al. [Kashif and Shafique, 2024] present an approach for efficiently training QNNs in the presence of noise when using NISQ devices.