Tutorials
qcr:2606.52495.1

Quantum Transfer Learning with PennyLane

This PennyLane tutorial demonstrates quantum transfer learning, a hybrid technique that combines a powerful pre-trained classical neural network with a trainable quantum circuit to classify images, making quantum machine learning practical on real, high-dimensional data. Transfer learning reuses a network trained on a large dataset as a fixed feature extractor and only trains a small new head on the task at hand; here the head is a variational quantum circuit. The tutorial takes a pre-trained ResNet image model from PyTorch, removes its final classification layer, and replaces it with a dressed quantum circuit (a quantum layer wrapped by small classical layers), then trains only that quantum head to distinguish image classes such as ants and bees. It uses PennyLane's TorchLayer to embed the QNode seamlessly into a PyTorch model so the whole thing trains with standard PyTorch optimizers and autograd, with quantum gradients supplied by PennyLane. The tutorial walks through loading the data and pre-trained model, building the hybrid network, and training and evaluating it. By leveraging classical pre-training, the demo shows a realistic, effective route to applying quantum models to genuine image-classification problems in PennyLane.
QML
Qubit
Circuit-based
Uploaded 2 days ago
16
Views
GitHub667
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

PennyLaneAI/demos
667238
README.md

Quantum Transfer Learning with PennyLane

This PennyLane tutorial demonstrates quantum transfer learning, a hybrid technique that combines a powerful pre-trained classical neural network with a trainable quantum circuit to classify images, making quantum machine learning practical on real, high-dimensional data. Transfer learning reuses a network trained on a large dataset as a fixed feature extractor and only trains a small new head on the task at hand; here the head is a variational quantum circuit. The tutorial takes a pre-trained ResNet image model from PyTorch, removes its final classification layer, and replaces it with a dressed quantum circuit (a quantum layer wrapped by small classical layers), then trains only that quantum head to distinguish image classes such as ants and bees. It uses PennyLane's TorchLayer to embed the QNode seamlessly into a PyTorch model so the whole thing trains with standard PyTorch optimizers and autograd, with quantum gradients supplied by PennyLane. The tutorial walks through loading the data and pre-trained model, building the hybrid network, and training and evaluating it. By leveraging classical pre-training, the demo shows a realistic, effective route to applying quantum models to genuine image-classification problems in PennyLane.

Run it

pip install -r requirements.txt
python demo.py

Source and license

Imported from demonstrations_v2/tutorial_quantum_transfer_learning/demo.py in PennyLaneAI/demos at c52c0abeb5122218aa96b38eea848864cce7323f, under the Apache License 2.0. Original authors: Xanadu and the PennyLane community. The upstream LICENSE is included alongside this example.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Versions

v1 Latest
Jun 16, 2026
qcr:2606.52495.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

PennyLane

Keywords

transfer-learning
quantum-machine-learning
pennylane
pytorch
hybrid

You may also like5