Quick Answer — What is Quantum Data Encoding? Quantum data encoding (also called a feature map) is the process of converting classical data — numbers, vectors, or images — into quantum states that a quantum circuit can process. The four main strategies are: Basis encoding (binary strings to computational basis states), Angle encoding (values as rotation angles), Amplitude encoding (values as state amplitudes), and Phase encoding (values in qubit phases). Each trades off qubit count, circuit depth, and expressibility differently.
The Bottleneck: Data Encoding#
In Quantum Machine Learning (QML), one of the most critical challenges is Data Encoding: the process of converting classical data into quantum states that a quantum computer can process.
This guide walks through interactive quantum encoding visualization and simulation of every major encoding strategy, so you can learn exactly how classical vectors map to qubit states in real time. Whether you're exploring amplitude encoding, angle encoding, basis encoding, or phase encoding, each method makes different trade-offs between circuit depth, qubit count, and expressibility.
If we have a classical dataset of -dimensional vectors, we need to map this data into the amplitudes or phases of a quantum system using a feature map.
Normalization and Information Loss: In classical machine learning, we often use min-max normalization. In quantum computing, however, the length of a quantum state vector must equal 1:
This means raw data must always be normalized, which can sometimes lead to a loss of relative magnitude information between different data points.
1. Basis Encoding#
Basis Encoding is the most straightforward approach. It represents each classical bit as a separate qubit, mapping a classical bit-string directly into a computational basis state of a quantum system.
For example, the classical vector :
The overall 12-bit string becomes a 12-qubit computational basis state:
Resource Cost: Requires qubits for an -dimensional feature vector. It is extremely expensive in terms of qubit count, making it difficult to scale on near-term hardware.
2. Amplitude Encoding#
Amplitude Encoding is exponentially more compact. It encodes a normalized classical -dimensional data vector directly into the amplitudes of an -qubit quantum system:
Where is the normalization constant, and is the -th computational basis state. Because qubits can represent basis states, we only need qubits.
Example: Encode
- Normalization:
- Encoded state:
The Catch: While Amplitude Encoding provides an exponential space advantage, preparing this state requires data loading circuits consisting of or CNOT gates, eliminating the exponential speedup during data preparation.
3. Angle Encoding#
Angle Encoding maps classical features directly to the rotation angles of individual qubits. We assign one qubit per feature, applying a rotation gate (usually or ) to a qubit initialized in the state:
If we encode features into qubits, the tensor product state looks like:
Best Practice: Since angles are periodic, you should rescale your classical data into the range or before encoding.
4. Phase Encoding#
Phase Encoding is related to Angle Encoding, but instead of rotating the qubit's measurement probabilities (which happens around the X or Y axis), we rotate it purely along the Z-axis, encoding the data into the phase of the quantum state.
Data is mapped with a phase-rotation gate: .
This requires two steps to be measurable:
- Apply a Hadamard Gate to place the qubit into superposition:
- Apply the Phase Gate:
The resulting state:
This method uses a circuit depth of 2 per qubit and maps features into the complex phase space.
5. Dense Angle Encoding#
Dense Angle Encoding mixes Angle Encoding and Phase Encoding to achieve a higher density: mapping two features into a single qubit.
For a single qubit, we map one feature using the Y-axis rotation, and the other feature using the Z-axis (Phase) rotation:
This results in the state:
By packing two features into one qubit, we can encode a 12-feature dataset into just 6 qubits.
Test Your Knowledge#
See It Live#
You can visualize Amplitude, Angle, and Basis encodings in our interactive quantum encoding simulator. Watch the Bloch spheres react instantly to your classical data inputs, with no setup required.