Quantum Circuit Lab / quantum machine learning
Lesson 12 · quantum machine learning

Data Encoding: Pushing Images and Text into Qubits

Compare basis, angle, and amplitude encoding and understand why data loading is often the bottleneck in quantum machine learning.

Advanced19 min readsoftware engineering · quantum computing

Three encoding families

EncodingIdeaTrade-off
BasisMap bits to |0⟩ and |1⟩.Simple, but loses continuous information.
AngleUse a feature as a rotation angle.Few qubits, but repeated features add depth.
AmplitudeNormalise a vector into state amplitudes.Compact, but state preparation can be expensive.

Angle encoding is a practical first experiment

for wire, value in enumerate(features[:n_qubits]):
    qml.RY(np.pi * value, wires=wire)

# add entanglers and trainable rotations after encoding

This is not “putting a whole image into four qubits”. It is a chosen feature map. You still decide how to reduce, scale, and order the original data.

Use a classical front end

A raw image or token sequence is too large for a small circuit. Use PCA, a small CNN, an embedding model, or another task-appropriate encoder to produce a compact vector, and state the compression step explicitly.

Honest claim: “uses a quantum layer” is not the same as “processes the full dataset quantumly”. Report dimensionality reduction, encoding cost, and circuit depth.

Put these choices together in the hybrid quantum–classical CNN architecture.