You are reading without signing in. Sign in or continue as guest to take quizzes and keep XP.
03Cutting and Quantum MLAdvanced10 min· 45 XP
Data encoding
Basis, angle and amplitude encoding: how classical data enters a circuit and what each choice costs.
You will learn to
- Encode a 4-dimensional vector three different ways.
- Compare qubit count and circuit depth per encoding.
- Explain 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 |
Try it
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.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];
Sign in to run (nothing is saved)
Quiz 1 · 10 XP
Amplitude encoding of 1024 features needs how many qubits?
Sign in to answer and earn XP; you will come back to this lesson.
Quiz 2 · 10 XP
Which statement about QML speed-ups is honest?
Sign in to answer and earn XP; you will come back to this lesson.
Key takeaway
Angle encoding is cheap and shallow, amplitude encoding is compact but deep. Always count the cost of getting data in before believing a speed-up.
Up next: QAOA on a small graph