Loading...
Loading...
When quantum meets neural networks
Quantum machine learning explores how quantum computers can accelerate or enhance machine learning tasks. This module covers variational quantum circuits, quantum kernels, and the current state of the field.
Variational Quantum Circuits (VQCs) are parameterized quantum circuits optimized using classical gradient descent. They are the quantum analog of neural networks — layers of gates with tunable parameters.
A VQC consists of three parts: data encoding (loading classical data into quantum states), a parameterized circuit (the quantum model), and measurement (extracting classical information).
Quantum kernel methods use a quantum computer to compute similarity measures (kernels) between data points in a high-dimensional quantum feature space. The kernel trick allows learning in this space without explicit feature mapping.
Quantum kernels can access feature spaces exponentially larger than classical kernels, potentially enabling better classification boundaries for certain datasets.
Quantum kernel
Feature map
QML is an active research area with both promise and challenges. Barren plateaus — exponentially vanishing gradients in large circuits — make training difficult. Data loading can erase quantum advantages.
However, QML may excel at specific tasks: learning from quantum data, certain structured datasets, and tasks where quantum feature spaces offer natural advantages. The field is evolving rapidly.
Run this code in your own environment to experiment with the concepts.
A simple variational classifier for binary classification.
import pennylane as qml
from pennylane import numpy as np
dev = qml.device('default.qubit', wires=2)
def layer(params):
qml.RX(params[0], wires=0)
qml.RY(params[1], wires=1)
qml.CNOT(wires=[0, 1])
@qml.qnode(dev)
def qnn(params, x):
qml.RY(x[0], wires=0)
qml.RY(x[1], wires=1)
for p in params:
layer(p)
return qml.expval(qml.PauliZ(0))
# Training would go here
params = [np.array([0.1, 0.2]) for _ in range(2)]
x = np.array([0.5, 0.3])
print('QNN output:', qnn(params, x))1. What is the main challenge when training deep variational quantum circuits?
2. What does a quantum kernel compute?
3. What type of data might QML naturally excel at processing?