Quantum machine learning is an emerging field at the intersection of quantum computing and machine learning that explores how quantum computers can be used to improve machine learning algorithms.
Quantum computing utilizes the principles of quantum mechanics to perform computations in ways that classical computers cannot. The basic unit of information in a quantum computer is the qubit, which can exist in a superposition of 0 and 1 states simultaneously. This allows quantum computers to process information in parallel, enabling significant speedups for certain problems.
Some key concepts in quantum computing:
Qubits - The basic unit of information in a quantum computer. Qubits can exist in a superposition of 0 and 1.
Entanglement - Qubits can be entangled with each other, allowing non-classical correlations between them.
Quantum gates - Operations that manipulate qubit states. Common single qubit gates include X, Y, Z, H (Hadamard). Two-qubit gates like CNOT allow entanglement.
Quantum circuits - Sequences of quantum gates that perform quantum algorithms.
Machine learning algorithms build mathematical models from sample data to make predictions or decisions without explicit programming.
Common types of machine learning include:
Supervised learning - Models are trained on labeled data. E.g. classification, regression.
Unsupervised learning - Models learn patterns from unlabeled data. E.g. clustering, dimensionality reduction.
Reinforcement learning - Models learn by interacting with an environment and receiving feedback.
Many machine learning models can be expressed as neural networks.
The weights and biases of the network are optimized during training to improve model accuracy. Stochastic gradient descent is commonly used for optimization.
Quantum machine learning explores how quantum computers can accelerate machine learning algorithms and enable new capabilities.
The main approaches include:
Using quantum algorithms as subroutines within classical machine learning pipelines.
Encoding data into quantum states for quantum-enhanced data analysis.
Representing machine learning models with quantum circuits and training via hybrid quantum-classical algorithms.
Quantum computers can accelerate certain computations within machine learning algorithms. Here are some key examples:
Many machine learning techniques rely heavily on linear algebra.
Quantum algorithms provide exponential speedups for some important linear algebra applications:
Matrix Inversion - Harrow-Hassidim-Lloyd algorithm
Principal Component Analysis - Quantum phase estimation
Solving Linear Systems - HHL algorithm
These can be used as subroutines in classical machine learning pipelines.
Some quantum algorithms can efficiently sample from probability distributions that are believed to be hard to sample from classically.
This is useful for generative modeling and reinforcement learning.
Examples include:
Quantum annealing - D-Wave quantum annealers can sample from Boltzmann distributions over binary variables.
Boson sampling - Photonic systems can sample from probability distributions related to scatterings of photons.
Quantum optimization algorithms like quantum annealing and the quantum approximate optimization algorithm (QAOA) can potentially optimize objective functions for machine learning models more efficiently than classical methods.
Instead of using quantum algorithms as subroutines, quantum machine learning can also encode data into quantum states to harness quantum effects for enhanced data analysis.
Kernel methods like support vector machines rely on computing kernel functions between data points. Quantum algorithms have been proposed for efficiently estimating kernel matrix elements, enabling large speedups.
Data can be encoded into quantum states, then quantum phase estimation used to identify clusters. Provides quadratic speedups over classical clustering algorithms.
Quantum principal component analysis (QPCA) uses quantum phase estimation to perform PCA on quantum-encoded data with exponential speedups over classical PCA.
Small quantum neural networks have been experimentally demonstrated. Larger versions could potentially perform quantum-enhanced neural network computations.
The most active area of quantum machine learning is designing quantum circuits that can represent machine learning models, then training these circuits via hybrid quantum-classical algorithms.
These circuits can be trained to perform tasks like classification and regression. The parameters are optimized to minimize a loss function.
Hybrid Quantum-Classical Training
Specialized hybrid algorithms are used to train parametrized quantum circuits:
Initialize randomly
Repeat until convergence: Prepare stateon quantum computer
Measure state to get predictions
Estimate gradient
Update via gradient descent This allows leveraging quantum effects like superposition and entanglement during training.
Parametrized quantum circuits can represent quantum neural networks. These can be trained via hybrid algorithms to perform supervised learning tasks.
Generative modeling involves learning a probability distribution from training data, then sampling from it. Parametrized quantum circuits can represent generative models, trained via hybrid algorithms.
Quantum circuits can represent reinforcement learning agents or environments. Hybrid training algorithms allow optimizing policies to maximize rewards.
Software frameworks for quantum machine learning make developing and testing algorithms, without requiring access to quantum hardware, possible.
Examples include:
Python framework for quantum differentiable programming from Xanadu.AI. Integrates with PyTorch, TensorFlow, JAX.
Code example:
dev = qml.device('default.qubit', wires=2)
@qml.qnode(dev) def circuit(weights): qml.RX(weights[0], wires=0) qml.RY(weights[1], wires=1) qml.CNOT(wires=[0,1]) return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
weights = np.array([0.1, 0.2]) print(circuit(weights))
Quantum machine learning library from Google AI Quantum. Integrated with TensorFlow.
code example: quantum convolutional networks
#Update package resources to account for version changes.
import importlib, pkg_resources importlib.reload(pkg_resources)
import tensorflow as tf import tensorflow_quantum as tfq
import cirq import sympy import numpy as np
#visualization tools
%matplotlib inline import matplotlib.pyplot as plt from cirq.contrib.svg import SVGCircuit
qubit = cirq.GridQubit(0, 0)
#Define some circuits.
circuit1 = cirq.Circuit(cirq.X(qubit)) circuit2 = cirq.Circuit(cirq.H(qubit))
#Convert to a tensor.
input_circuit_tensor = tfq.convert_to_tensor([circuit1, circuit2])
#Define a circuit that we want to append
y_circuit = cirq.Circuit(cirq.Y(qubit))
#Instantiate our layer
y_appender = tfq.layers.AddCircuit()
#Run our circuit tensor through the layer and save the output.
output_circuit_tensor = y_appender(input_circuit_tensor, append=y_circuit)
#Input tensor
print(tfq.from_tensor(input_circuit_tensor))
#output tensor
print(tfq.from_tensor(output_circuit_tensor))
IBM's open source quantum computing framework. Includes Aqua library for quantum machine learning.
code example:
#Create a Quantum Circuit
meas = QuantumCircuit(3, 3) meas.barrier(range(3))
#map the quantum measurement to the classical bits
meas.measure(range(3), range(3))
#The Qiskit circuit object supports composition using
#the compose method.
circ.add_register(meas.cregs[0]) qc = circ.compose(meas)
#drawing the circuit qc.draw()
#Use Aer's qasm_simulator
backend_sim = Aer.get_backend('qasm_simulator')
#Execute the circuit on the qasm simulator.
#We've set the number of repeats of the circuit
#to be 1024, which is the default.
job_sim = backend_sim.run(transpile(qc, backend_sim), shots=1024
#Grab the results from the job.
result_sim = job_sim.result()
Quantum computers can efficiently simulate quantum systems, providing a significant advantage for computational chemistry. This could accelerate drug discovery and materials science applications.
Combinatorial optimization problems abound in logistics, scheduling, and more. Quantum optimization algorithms like QAOA offer a quantum advantage for many optimization problems.
Quant finance relies heavily on Monte Carlo sampling for risk analysis, option pricing, and portfolio optimization. Quantum sampling provides speedups for these applications.
Reinforcement learning is used to train AI agents to perform control tasks. Quantum enhancements to RL could accelerate training of quantum control systems.
While promising, there are still significant challenges in quantum machine learning:
Noisy intermediate-scale quantum (NISQ) computers have high error rates and limited qubit numbers. This restricts model complexity.
Lack of robust software tools and frameworks for QML development.
Finding useful applications to provide quantum advantage remains challenging.
However, rapid progress is being made both on the hardware and software side to address these challenges. Here are some key areas to watch for future developments:
While there are still significant challenges ahead, quantum machine learning is a rapidly advancing field that offers much promise for the future of AI and data analysis. Ongoing hardware and software developments will help transition quantum machine learning from theoretical proposals into practical implementations over the next decade. This will open the door to leveraging the unique capabilities of quantum computers to accelerate machine learning and enable new quantum-enhanced algorithms.
Biamonte, Jacob, et al. "Quantum machine learning." Nature 549.7671 (2017): 195-202.
Ciliberto, Carlo, et al. "Quantum machine learning: a classical perspective."
Harrow, Aram W., Avinatan Hassidim, and Seth Lloyd. "Quantum algorithm for linear systems of equations."
Lloyd, Seth, et al. Physical review letters 103.15 (2009): 150502.
Mitarai, Katsuhiro, et al. "Quantum algorithms for supervised and unsupervised machine learning." arXiv preprint arXiv:1307.0411 (2013).
Schuld, Maria, et al. "An introduction to quantum machine learning." Contemporary Physics 56.2 (2015): 172-185.
Venegas-Andraca, Salvador E. "Quantum walks: a comprehensive review." Quantum Information Processing 11.5 (2012): 1015-1106.
Wittek, Peter. "Quantum machine learning: what quantum computing means to data mining." (2014).
Zhao, Zhikuan, et al. "Quantum machine learning in finance." Machine Learning: Science and Technology 2.2 (2021): 025003.
All images from Bing Image Creator and Hackernoon Image Generator.