Curriculum / Quantum Machine Learning / Quantum Transfer Learning

Lesson 11 of 15Code challengePro+175 XP

Quantum Transfer Learning

Combine classical neural networks with a quantum circuit layer.

Quantum Transfer Learning

The Hybrid Approach

Transfer learning uses a pre-trained classical model as a feature extractor and attaches a small trainable layer on top. In quantum transfer learning, that trainable layer is a parameterized quantum circuit (PQC).

The idea: classical networks (ResNet, BERT, etc.) learn rich feature representations from large datasets. These features can be re-used for new tasks by attaching a small task-specific head. Replacing this head with a quantum circuit is quantum transfer learning.

The Architecture

Classical Transfer Learning: Pre-trained CNN -> Feature vector (512D) -> Classical dense layer -> Output

Quantum Transfer Learning: Pre-trained CNN -> Feature vector (512D) -> Dimensionality reduction -> PQC (n qubits) -> Measurement -> Output

The PQC has n qubits, so we reduce the feature vector to n values (e.g., via PCA or just taking the first n features). These n values are encoded as rotation angles.

Encoding the Classical Features

Given n classical features from the pre-trained model:

  1. 1.Angle encoding: Apply for each feature
  2. 2.Entanglement layer: CNOT gates to create correlations
  3. 3.Variational layer: for each trainable angle

Only the variational layer angles are updated during training. The encoding angles come from the frozen pre-trained model.

Why This Might Help

The PQC variational layer operates in a -dimensional Hilbert space. For n=4 qubits, that is 16 dimensions. The hypothesis: this larger feature space might allow better separation of classes even with few training examples.

Experimental evidence is mixed. On small datasets, quantum transfer learning sometimes matches classical dense layers. On large datasets, classical layers typically win due to hardware limitations.

Practical Considerations

When implementing quantum transfer learning:

  • Keep n small (4-8 qubits) to match current hardware
  • Use multiple variational layers (L=2-4) for expressibility
  • The entanglement pattern matters: linear vs. all-to-all connectivity
  • Gradient computation uses the parameter shift rule on the PQC layer only

This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.

How this lesson works

A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.

Part of: Quantum Machine Learning

Apply quantum computing to machine learning with variational circuits and optimization.

This lesson is part of Pro

Unlock Quantum Machine Learning and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.