Quantum Convolutional Neural Networks¶
This note describes the QCNN classifier implemented in qml.qcnn.
The current implementation is intentionally compact and package-oriented:
- four-qubit trainable input embedding
- shared local convolution-style blocks
- pooling-style entangling reductions
- final single-qubit readout for binary classification
Overview¶
A quantum convolutional neural network mirrors the high-level idea of a classical CNN: local processing is applied first, and information is then compressed into a smaller effective representation before the final readout.
In this repository, the QCNN classifier acts on a fixed four-qubit register and is trained directly on synthetic binary classification datasets.
Model structure¶
Let the embedded input state be
The QCNN applies a hierarchical circuit of the form
The components are:
U_emb: trainable feature embedding using data-dependent single-qubit rotationsU_conv,1: first-stage shared two-qubit convolution blocks on neighbouring pairsU_pool: pooling-style entangling reductionsU_conv,2: second-stage convolution on the reduced representationU_dense: final single-qubit rotations before readout
Readout and loss¶
The model measures a Pauli-\(Z\) expectation on the readout qubit:
This expectation is mapped to a binary probability:
Training minimizes binary cross-entropy over the training set.
Example usage¶
from qml.qcnn import run_qcnn
result = run_qcnn(
dataset="moons",
n_samples=200,
steps=50,
step_size=0.1,
)
Outputs include:
- flattened trainable parameters
- structured QCNN parameter blocks
- training and test accuracy
- optimisation loss history
- predicted probabilities on train and test splits
When save=True, the workflow writes JSON results and generated figures to:
results/qcnn/images/qcnn/
Relationship to Other Models¶
Compared with the existing VQC workflow:
- VQC uses a repeated global ansatz template
- QCNN uses an explicitly hierarchical convolution/pooling structure
Compared with quantum kernels:
- QCNN learns a direct discriminative classifier
- kernel workflows learn similarity structure and rely on a classical SVM readout
When to Use QCNN¶
QCNN is useful when:
- you want a more structured architecture than a flat variational circuit
- local hierarchical feature extraction is a better inductive bias
- you want a classifier that differs materially from the existing VQC workflow
References¶
Cong et al. (2019) Quantum convolutional neural networks.