Overview of quantum neural networks and examples of algorithms and implementations

Machine Learning Technology Artificial Intelligence Technology Natural Language Processing Technology Probabilistic Generative Models Algorithm ICT Technology Computer Architecture IT Infrastructure Technology Digital Transformation Technology Deep Learning Mathematics
quantum neural network

Quantum Neural Networks (QNN) are an attempt to utilise the capabilities of quantum computers to realise neural networks, as described in ‘Quantum Computers Accelerate Artificial Intelligence’, which aims to extend or improve conventional machine learning algorithms by utilising the properties of quantum mechanics. It aims to extend or improve conventional machine learning algorithms by exploiting the properties of quantum mechanics.

The characteristics of QNNs include the following.

  • Use of quantum bits (Qubit): quantum bits, unlike conventional bits (0 or 1), can have superposition states. This property allows many states to be processed in parallel at once.
  • Quantum entanglement: QNNs utilise quantum entanglement to create strong correlations between nodes in a neural network, enabling efficient information transfer.
  • Manipulation by quantum gates: QNNs use quantum gates to adjust the weights and biases of the network. This improves computational efficiency.

The following structures are considered for QNNs

  • Fusion of quantum and classical layers: many QNNs employ a hybrid architecture combining quantum and classical layers. This takes the form of processing the features in the quantum layer and evaluating the results in the classical layer.
  • Circuit-based design: a QNN consists of a quantum circuit and the operations within the circuit (e.g. unitary transformations) correspond to the processing of a neural network.

Applications of QNNs include

  • Quantum machine learning: utilising the parallelism of quantum computers to speed up the processing of large data sets and the training of models.
  • Optimisation problems: applications to combinatorial and constrained optimisation problems.
  • Pattern recognition: new possibilities in areas where conventional neural networks excel, such as image recognition and natural language processing.

Challenges include the quantum decoherence problem, where quantum states collapse under the influence of the environment, hardware limitations of current quantum computers with small scale and low noise tolerance, and the immaturity of algorithms where research into optimal algorithms specific to QNNs is still in its early stages.

To address these issues, tools are available to support the development of QNNs, such as Google’s Cirq and IBM’s Qiskit, and the development of superconducting qubits and ion trapping technology is making QNNs more practical.

Although QNNs are still a developing field, they have the potential to exploit the full potential of quantum computers.

Related Algorithms

The main algorithms involved in the construction and training of QNNs are described below.

1. variational quantum circuit (VQC)

  • Abstract: Variational quantum circuits are one of the most commonly used approaches in quantum computing, where the parameters of the quantum circuit are tuned and optimised. The parameters are updated using conventional classical optimisation algorithms (e.g. gradient descent).
  • Features: in QNN, the quantum layer is designed using VQC, where the angle and order of operation of the quantum gates correspond to weights and biases.

2. Quantum Approximate Optimisation Algorithm (QAOA)

  • Abstract: QAOA is a quantum algorithm for solving combinatorial optimisation problems, but it has also been applied to QNN. By controlling the depth of the quantum circuit, the accuracy and cost of the computation can be tuned.
  • Features: particularly useful for constrained optimisation problems and graph-based problems, and adaptable to learning tasks, using parametric quantum circuits.

3. quantum principal component analysis (QPCA)

  • Abstract: QPCA is a method for extracting the principal components of a quantum state. It is used for dimensionality reduction and feature extraction of high-dimensional data and can be applied as a pre-processing step for QNN.
  • Features: efficient processing of the quantum state of the data. Potentially exponentially faster than classical PCA.

4. quantum Boltzmann Machines (QBM)

  • Abstract:a quantised model of classical Boltzmann machines. Optimises energy states using quantum entanglement and quantum tunneling.
  • Features: energy-based model, applicable to generative modelling and reinforcement learning. A wider state space can be explored than with classical Boltzmann machines.

5. quantum support vector machine (QSVM)

  • Abstract: A quantum computer implementation of a support vector machine (SVM). The computation of kernel functions is made more efficient by quantum circuits, improving classification performance in high-dimensional spaces.
  • Features: can be integrated into sub-modules of a classification task as part of a QNN. Fast performance for large data sets.

6. quantum feedforward neural network (QFNN)

  • Abstract: A quantised version of the conventional feedforward neural network. Encodes input data as quantum states and computes outputs through quantum circuits.
  • Features: efficient computation using unitary operations (quantum gates). Feature transformation utilising quantum entanglement in the intermediate layer.

7.Quantum Backpropagation Algorithm

  • Abstract: Algorithm adapting conventional backpropagation to the quantum environment. Efficient methods for gradient computation in quantum circuits are being investigated.
  • Features: weights are adjusted by directly manipulating quantum states. Requires a design that takes quantum error correction into account.

8.Amplitude Amplification

  • Abstract: A technique based on Grover’s algorithm, which emphasises the amplitude of a particular state. Applicable to activation functions and node selection in neural networks.
  • Features: improves efficiency of search problems and activation functions; contributes to improving the convergence speed of QNNs.

9. quantum reinforcement learning

  • Abstract: Quantises the concept of reinforcement learning and represents the behaviour policy of an agent as a quantum state, using the QNN as the agent’s value function and policy function.
  • Features: effectively learns behaviour in high-dimensional search spaces. Fast policy search using superposition of quantum states.

10. Quantum Convolutional Neural Networks (QCNN)

  • Abstract: Quantum version of Convolutional Neural Networks (CNN). Captures local features of the data as quantum states.
  • Features: efficient manipulation of feature maps. Potential next-generation solution for large-scale image data.
Implementation example

The following will be an example implementation of a quantum neural network (QNN), showing how to use mainstream quantum computing libraries such as Google’s Cirq and IBM’s Qiskit.

1. example implementation of a QNN using Qiskit: in this example, a QNN is built to solve a two-class classification problem using variational quantum circuits (VQC).

Installing the required libraries.

pip install qiskit qiskit-machine-learning numpy

code example

import numpy as np
from qiskit import Aer
from qiskit.circuit.library import RealAmplitudes
from qiskit.utils import algorithm_globals
from qiskit_machine_learning.algorithms import VQC
from qiskit_machine_learning.kernels import FidelityQuantumKernel
from qiskit_machine_learning.neural_networks import SamplerQNN
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import accuracy_score

# Setting the random number seed.
algorithm_globals.random_seed = 42

# Generating datasets.
X, y = make_classification(n_samples=100, n_features=2, n_classes=2, random_state=42)
X = MinMaxScaler().fit_transform(X)  # Scaling of features to [0, 1].
y = 2 * y - 1  # Convert labels to {-1, 1}

# Splitting training and testing
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Quantum circuit design
quantum_circuit = RealAmplitudes(num_qubits=2, reps=3)

# Building a QNN
backend = Aer.get_backend('statevector_simulator')
qnn = SamplerQNN(
    circuit=quantum_circuit,
    input_params=quantum_circuit.parameters[:2],
    weight_params=quantum_circuit.parameters[2:]
)

# Initialisation of the VQC algorithm.
vqc = VQC(
    neural_network=qnn,
    optimizer='COBYLA',
    initial_point=np.random.rand(quantum_circuit.num_parameters),
    feature_map=quantum_circuit,
    var_form=quantum_circuit
)

# training
vqc.fit(X_train, y_train)

# test
y_pred = vqc.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print(f"test accuracy: {accuracy:.2f}")

2. example implementation of quantum machine learning with Cirq: example of building a simple quantum classifier with Cirq.

Installation of required libraries.

pip install cirq numpy

code example

import numpy as np
import cirq
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import accuracy_score

# Generating datasets.
X, y = make_classification(n_samples=100, n_features=1, n_classes=2, random_state=42)
X = MinMaxScaler().fit_transform(X)  # Scaling of features to [0, 1].
y = 2 * y - 1  # Convert labels to {-1, 1}

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Preparing the quantum bit.
qubit = cirq.GridQubit(0, 0)

# Quantum circuit design
def create_circuit(x, theta):
    circuit = cirq.Circuit()
    circuit.append(cirq.ry(2 * np.pi * x).on(qubit))
    circuit.append(cirq.rx(2 * np.pi * theta).on(qubit))
    return circuit

# Model definition.
def predict(X, theta):
    predictions = []
    simulator = cirq.Simulator()
    for x in X:
        circuit = create_circuit(x[0], theta)
        result = simulator.simulate(circuit)
        prob = np.abs(result.final_state_vector[0]) ** 2
        predictions.append(1 if prob > 0.5 else -1)
    return np.array(predictions)

# optimisation
theta = 0.5  # initial value
learning_rate = 0.1
for epoch in range(10):
    y_pred = predict(X_train, theta)
    error = y_train - y_pred
    gradient = -np.dot(error, X_train[:, 0])
    theta -= learning_rate * gradient

# test
y_pred_test = predict(X_test, theta)
accuracy = accuracy_score(y_test, y_pred_test)
print(f"test accuracy: {accuracy:.2f}")

Implementation points

  1. Hardware selection: the IBM Quantum and Google Quantum platforms can be used if actual quantum computers are used.
  2. Data pre-processing: data that can be handled by a quantum computer must basically be scaled to normalised values ([0, 1]).
  3. Quantum circuit design: the structure of the quantum circuit (gate operation) should be designed appropriately for the task.
reference book

Reference books related to quantum neural networks (QNN) and quantum machine learning are described below.

1. fundamentals of quantum computingQuantum Supremacy: How the Quantum Computer Revolution Will Change Everything

– Description: Provides easy-to-understand explanations for beginners, from the basics of quantum mechanics to the mechanism of quantum computers.

Quantum Computation and Quantum Information by Michael A. Nielsen and Isaac L. Chuang
– Publisher: Cambridge University Press
– Description: Known as the ‘holy book’ of quantum computing, this book covers everything from theoretical foundations to applications.

2. introduction to quantum machine learning
Quantum Machine Learning: An Applied Approach
– Author(s): Santanu Ganguly, Sudipta Hazra
– Publisher: Springer
– Description: learn quantum machine learning algorithms and implementation examples using Python and Qiskit.

Machine Learning with Quantum Computers
– Author(s): Maria Schuld, Francesco Petruccione
– Publisher: Springer
– Description: explains the basic concepts of quantum machine learning, as well as variational quantum algorithms and quantum kernel methods.

3. applications and implementations
Programming Quantum Computers: Essential Algorithms and Code Samples
– Authors: Eric R. Johnston, Nic Harrigan, Mercedes Gimeno-Segovia
– Publisher: O’Reilly Media
– Description: a practical guide to programming quantum algorithms using Qiskit and Cirq.

Quantum Computing for Computer Scientists
– Authors: Noson S. Yanofsky, Mirco A. Mannucci
– Publisher: Cambridge University Press
– Description: explains the algorithms and theory of quantum computing from a computer science perspective.

4. practical books
FUNDAMENTAL PYTHON PROGRAMMING FOR QUANTUM COMPUTING WITH QISKIT AND CIRQ: A Comprehensive Guide to Building Quantum Algorithms and Simulation with Python
– Description: Contains a wealth of example implementations of quantum programming using the Python library Qiskit.

Learning by Running Quantum Computers
– Author: Takaaki Takeda
– Publisher: Gijutsu-Hyohronron-Sha
– Description: Explains how to actually design quantum circuits and run them on a quantum computer. 5.

5. latest research and applications
Quantum Machine Learning: What Quantum Computing Means to Data Mining by Peter Wittek
– Publisher: Academic Press
– Description: A compact overview of advanced research in quantum machine learning.

Quantum Machine Learning.
– Description: Covers the theoretical background and latest applications of quantum machine learning.

6. reference papers
Quantum Computation and Quantum Information by Michael A. Nielsen and Isaac L. Chuang
Hybrid quantum-classical neural networks with PyTorch and Qiskit

コメント

タイトルとURLをコピーしました