L29 Quantum Machine Learning and Data Encoding
Overview
Quantum machine learning uses quantum states, parameterized circuits, superposition, and entanglement to represent or process data, but exponential speedups are not established and classical data encoding can be costly. Hiu-Yung Wong compares basis, amplitude, angle, phase, and multi-feature encodings, showing trade-offs such as 12 qubits for three 4-bit features versus 2 qubits for a three-component amplitude-encoded vector, while reviewing Qiskit feature maps and quantum-circuit concepts.
Key takeaways
- Quantum machine learning has no guaranteed speedup: classical data loading can be expensive, and some proposed quantum algorithms have classical counterparts with only polynomially different complexity.
- Basis encoding of three 4-bit features uses 12 qubits, while amplitude encoding fits a three-value vector into 2 qubits; the latter shifts cost from qubit count to state-preparation depth.
- Amplitude encoding of [4, 8, 5] requires normalization by √105, demonstrating that a valid quantum state must have unit norm.
- Angle and phase encoding use one qubit per feature; angle encoding stores data in rotation-dependent amplitudes, while phase encoding stores it as a relative phase in a superposition.
- Dense angle encoding can place two features on one qubit, and Qiskit feature maps add controlled interactions such as ZZ terms to create entanglement.
- Quantum circuits remain linear transformations; claims of nonlinearity in quantum machine learning refer to the circuit's dependence on classically encoded data and on measurement.
Chapters
- Quantum computing and machine learning both rely heavily on linear algebra, especially matrix multiplication.
- Claims of exponential speedup often concern special cases; Wong cautions that useful, general advantages remain unproven.
- Potential quantum-computing applications include fabrication, device control, and data analysis.
- A quantum neural network encodes data in parameterized gates such as an X-axis rotation, with angles set by data features.
- Training adjusts circuit parameters theta, while a classical computer such as an NVIDIA GPU computes gradients from measurement results.
- Repeated data encoding, circuit layers, and measurements provide a trainable model, but do not by themselves prove faster computation.
- A support vector machine separates classes with a hyperplane, using a kernel to represent data in a higher-dimensional feature space.
- A quantum kernel estimator can use inner products between encoded quantum states to estimate kernel values.
- A two-dimensional example becomes separable after adding a third feature, illustrating why high-dimensional mappings may help classification.
- Quantum machine learning can concern quantum data, quantum processing, or algorithms; the lecture focuses mainly on algorithms because practical quantum memory is limited.
- Loading classical data into quantum states is a major cost that can undermine a claimed algorithmic advantage.
- Some proposed quantum algorithms have been dequantized, meaning classical algorithms achieve comparable performance up to polynomial differences.
- Each example, such as an 8-by-8 image, can be flattened into a 64-element vector; a dataset contains many such vectors.
- Quantum feature mapping converts each classical vector into a quantum state, which must have unit norm.
- Encoding a large collection of high-resolution images makes data preparation and state loading central practical challenges.
- Basis encoding represents a feature value as a computational-basis bit string, using the binary forms of decimal values 5, 7, and 0.
- With four bits allotted to each of three features, the example image uses 12 qubits: 0101, 0111, and 0000.
- The method is straightforward to prepare, but requires roughly the number of features times the bits per feature in qubits.
- Most-significant-bit and least-significant-bit ordering must be tracked consistently when interpreting circuits.
- Amplitude encoding places vector entries into the coefficients of computational-basis states, then normalizes the resulting quantum state.
- A three-entry vector [4, 8, 5] fits in two qubits, with normalization factor √(4² + 8² + 5²) = √105.
- A vector of length n requires about log₂(n) qubits, but preparing its amplitudes can require a deeper, more complex circuit.
- This creates a space-time trade-off: fewer qubits than basis encoding, but more involved state preparation.
- Angle encoding maps each feature to a rotation angle, for example by applying RY(xₖ) to the qubit state |0⟩.
- The resulting amplitudes are cos(xₖ/2) and sin(xₖ/2), so one qubit represents each feature.
- Unlike amplitude encoding, angle encoding still needs one million qubits for one million features.
- Because rotation outcomes repeat with periodicity, input values may need rescaling to a range such as 0 to 2π.
- Phase encoding applies a phase-shift gate to a superposition, typically prepared with a Hadamard gate.
- For one feature xₖ, the state becomes (|0⟩ + e^(ixₖ)|1⟩)/√2, placing the data in a relative phase.
- The encoding uses one qubit per feature, and the Hadamard gate is needed to create the superposition on which the phase acts.
- A global phase is physically irrelevant; relative phase can affect measurement outcomes and interference.
- Dense angle encoding combines an RY rotation for one feature with a phase rotation for a second feature on the same qubit.
- Pairing features reduces the qubit count to roughly half the number of features, while retaining data in both rotation and phase.
- The lecture relates the resulting state to Bloch-sphere parameterizations, where global phase can be factored out.
- The encoding increases information per qubit but makes the state representation and circuit behavior more involved.
- A more elaborate Qiskit encoding maps four parameters onto two qubits using rotation and phase-shift gates.
- The circuit combines dense encoding with controlled-NOT operations to introduce entanglement between qubits.
- The gate sequence can be repeated to build a richer feature map, though the lecture emphasizes the concept rather than memorizing the full circuit.
- Qiskit's ZFeatureMap begins with Hadamard and phase gates, corresponding to a phase-encoding pattern.
- Repeating feature-map operations can create richer, data-dependent behavior for variational algorithms and quantum machine learning.
- The quantum circuit remains linear as a matrix operation; nonlinearity refers to how its output depends on the encoded input data.
- The ZZFeatureMap uses an interaction proportional to exp(-iθ Z⊗Z/2), whose diagonal form makes exponentiation direct.
- For θ = π/2, the two-qubit ZZ interaction yields a diagonal phase pattern proportional to diag(1, i, i, 1), producing entanglement.
- Wong recommends tracing selected parts of algorithms and performing matrix calculations rather than memorizing a complete algorithm such as Shor's.
- Final preparation should include reworking assignments and midterm problems from scratch, reviewing circuit notation, and checking MSB/LSB conventions.
- The final allows one two-sided cheat sheet, and questions may ask students to prove gate identities or trace a circuit component.
Transcript excerpt
0:07 Last time I talk about a part of the quantum machine learning, but here I just want to repeat, right? So I think AI and quantum computing is very close to each other because mathematically they both rely heavily on linear algebra. We can use quantum computer to speed up machine learning. That's what we try to see here, but I cannot cover all of them, but I will just have scratch the surface. But you need there are lots of caveats. Quantum machine learning is just like other quantum computing algorithm. There are lots of caveat. They say you may speed up exponentially or whatever. There's no proof and very often they only have a very special case that can speed up but useless case, okay? So just be careful of that. And of course quantum machine learning can be
0:56 used to make a quantum computer including from fabrication to control to data analysis. So last time I talk about what is machine learning. You use data to train machine. It can be supervised learning, unsupervised learning or reinforcement learning. The main point here is that you have a lots of data and a lots of computation and that make you think maybe we should use quantum computing. One of them is neural network. Neural network is nothing but just we have many layers. Each layer is better and then you go from one layer to another layer through this matrix multiplication. And matrix multiplication is what you did in your project, right? I asked you to write a simulator, quantum computer simulator that is basically just matrix
1:45 multiplication. But when you go to very huge matrix, what if it is 1 billion by 1 billion instead of the 8 by 8 that you are doing in your class project that
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Quantum Computing, TCAD, Semicond by Hiu-Yung Wong.