You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.
Data encoding
Basis, angle and amplitude encoding: how classical data enters a circuit and what each choice costs.
Advanced10 min read4 sections · 2 questions+45
By the end you will be able to
- 01Encode a 4-dimensional vector three different ways.
- 02Compare qubit count and circuit depth per encoding.
- 03Explain why encoding dominates many QML costs.
| Encoding | Qubits for N features | Depth | Note |
|---|---|---|---|
| Basis | N (bits) | 1 | x = 0101 → |0101⟩; only for binary data |
| Angle | N | 1 | feature xᵢ → ry(xᵢ) on qubit i; simple and hardware-friendly |
| Amplitude | log₂ N | O(N) | x becomes the statevector itself; exponentially compact, exponentially deep to prepare |
Hands-on
Angle-encode (0.3, 1.2, 2.0, 0.7)
Four features, four qubits, one layer. The Bloch view shows each qubit tilted by its feature. Add a second layer of CNOTs and RYs to see how a feature map creates correlations the model can use.
OpenQASM 3
OPENQASM 3.0;
include "stdgates.inc";
qubit[4] q;
ry(0.3) q[0];
ry(1.2) q[1];
ry(2.0) q[2];
ry(0.7) q[3];
Knowledge check
2 questions · one try each counts
Question 1
Amplitude encoding of 1024 features needs how many qubits?
Sign in to answer and climb the ranks; you will come back to this lesson.
Question 2
Which statement about QML speed-ups is honest?
Sign in to answer and climb the ranks; you will come back to this lesson.