Image Compression and Classification Using Qubits and Quantum Deep Learning

Ali Mohsen, Mo Tiwari

TL;DR

Current quantum neural networks (QNNs) struggle with classical images because standard qubit-per-pixel encodings require too many qubits, restricting benchmarks to unreadable $4 \times 4$ images. This paper introduces an efficient image-encoding scheme based on the Flexible Representation of Quantum Images (FRQI) and specialized QNN layers (CRADL), enabling classification of up to $16 \times 16$ MNIST digits using only 8 qubits and achieving performance competitive with parameter-matched classical networks.

What Problem Does This Paper Address?

Quantum Machine Learning (QML) promises computational advantages, but applying QNNs to computer vision suffers from a severe bottleneck: data encoding.

Most prior quantum classifiers rely on injective mappings where each classical pixel demands its own qubit. Because near-term quantum computers and classical simulators are limited to dozens of qubits, previous research had to downsample images to $4 \times 4$ pixels—a resolution so coarse that even humans cannot consistently recognize the digits. To scale QML to realistic image sizes, models need encoding schemes that exploit quantum superposition and entanglement to represent images using exponentially fewer qubits.

Methods

The authors tackle encoding efficiency, circuit compilation, and network architecture through several techniques:

  1. Flexible Representation of Quantum Images (FRQI): Instead of dedicating a qubit to each pixel, FRQI encodes $2^{2n}$ pixel coordinates as basis states in a superposition across $2n$ "pixel qubits," storing binary color in a single "color qubit" rotation.
  2. Decomposition into 2-Qubit Gates: Simulating and training QNNs in software like TensorFlow Quantum (TFQ) requires decomposing complex $n$-controlled unitary rotations (generalized Toffoli gates) into 2-qubit operations. The authors recursively compile these into sequences of CNOT and single-qubit gates, enabling exact parameter-shift gradient computation.
  3. Extra Compression via Phase Packing ($-2\text{Q}$): The authors introduce a compression method that maps the state of two pixel qubits directly into the rotation angle $\tilde{\theta}_q$ of the color qubit, further reducing the required circuit width by 2 qubits.
  4. CRADL & CRAML Architectures: To process this entangled representation, they introduce the Color-Readout-Alternating-Double-Layer (CRADL) and mixed-layer (CRAML) architectures. These layers apply parameterized two-qubit exponential Pauli rotations ($XX$ and $ZZ$) alternating between pixel–readout and pixel–color qubits.
  5. Readout and Training: A dedicated readout qubit is initialized in the $|+\rangle$ state. Predictions are extracted by measuring the expectation value $\langle Z \rangle$ on the readout qubit, trained end-to-end with hinge loss and stochastic gradient descent (SGD).
[Pixel Qubits]  ───(H⊗2n)───■───────■─────── [XX / ZZ] ───
                            │       │            │
[Color Qubit]   ────────────R(θ)────┼─────── [XX / ZZ] ───
                                    │            │
[Readout Qubit] ───( H )────────────■─────── [XX / ZZ] ─── Meas ⟨Z⟩

Datasets

  • MNIST (Handwritten Digits): Following prior work, the authors focus on binary classification between digits 3 and 6 (~12,000 training and ~1,100 validation images).
  • Images are downsampled via bilinear interpolation to $8 \times 8$ and $16 \times 16$, then binarized (thresholded into pure black and white). No new benchmarks were created.

Key Insights and Ideas

  • Hilbert Space Dimensionality over Physical Qubit Count: By embedding image geometry into quantum basis states rather than separate qubits, a $16 \times 16$ image (256 pixels) can be processed on only 8 qubits (6 pixel, 1 color, 1 readout when using $-2\text{Q}$ compression).
  • Analytic Gradients via Specialized Ansatzes: General unitaries scale exponentially in parameters ($2^{2n}$) and hinder optimization. Restricting layers to single-parameter multi-qubit Pauli rotations ($XX$ and $ZZ$) enables exact parameter-shift differentiation while preserving high expressivity.
  • The Compression vs. Expressivity Trade-off: Packing coordinate information into color rotation angles cuts qubit requirements, but it compresses the state space in ways that measurably degrade classification performance.

Key Results

The quantum models were benchmarked on a standard laptop against parameter-matched classical neural networks (two hidden ReLU layers):

Resolution Model Learnable Parameters Test Accuracy
$8 \times 8$ Classical CNN 65 $94 \pm 1\%$
Quantum CRADL (6 qubits) 72 $92 \pm 1\%$
Quantum CRADL $-2\text{Q}$ (4 qubits) 64 $88 \pm 1\%$
$16 \times 16$ Classical CNN 257 $98.9 \pm 0.3\%$
Quantum CRADL $-2\text{Q}$ (6 qubits) 252 $90 \pm 1\%$

On $8 \times 8$ images, the uncompressed QNN matches classical network accuracy within 2 percentage points. While the compressed model ($-2\text{Q}$) drops in accuracy, it allows $16 \times 16$ QNN training to run on modest consumer hardware (a MacBook Pro CPU).

Limitations and Future Work

  • Circuit Depth & Gate Complexity: While qubit count scales logarithmically with image size, the gate count required to compile the encoding state grows exponentially ($\le 2^n(2 \cdot 3^n - 1)$ controlled gates).
  • Strict Binarization: Experiments are restricted to binary (black/white) pixel values and binary digit classification (3 vs. 6).
  • Simulation Only: Results were evaluated using classical simulation (Cirq and TensorFlow Quantum), leaving real-device noise and decoherence uncharacterized.
  • Future Directions: The authors suggest exploring 3+ qubit entangling gates, optimizing encoding circuits to reduce overall gate depth, and evaluating quantum compression as an implicit regularizer.

Summary updated

Abstract

Recent work suggests that quantum machine learning techniques can be used for classical image classification by encoding the images in quantum states and using a quantum neural network for inference. However, such work has been restricted to very small input images, at most $4 \times 4$, that are unrealistic and cannot even be accurately labeled by humans. The primary difficulties in using larger input images is that hitherto-proposed encoding schemes necessitate more qubits than are physically realizable. We propose a framework to classify larger, realistic images using quantum systems. Our approach relies on a novel encoding mechanism that embeds images in quantum states while necessitating fewer qubits than prior work. Our framework is able to classify images that are larger than previously possible, up to $16 \times 16$ for the MNIST dataset on a personal laptop, and obtains accuracy comparable to classical neural networks with the same number of learnable parameters. We also propose a technique for further reducing the number of qubits needed to represent images that may result in an easier physical implementation at the expense of final performance. Our work enables quantum machine learning and classification on classical datasets of dimensions that were previously intractable by physically realizable quantum computers or classical simulation.
BibTeX
@inproceedings{mohsen2022image,
  author = {Ali Mohsen and Mo Tiwari},
  title = {{Image Compression and Classification Using Qubits and Quantum Deep Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=t1QXzSGwr9},
}

Loading related content...

Figure