Code
qcr:2606.36748.1

Quantum GANs with PennyLane

This PennyLane demo implements a Quantum Generative Adversarial Network (QGAN), adapting the adversarial-training paradigm of classical GANs to quantum circuits to learn and generate data distributions. A GAN pits two networks against each other: a generator that learns to produce realistic samples and a discriminator that learns to distinguish real from generated data, with the two improving through competition. In this demo the generator is built from quantum circuits, specifically a patched approach where several sub-generator circuits each produce part of the output so that limited-qubit circuits can generate higher-dimensional data. The tutorial implements the quantum generator in PennyLane, wraps it for training with PyTorch, pairs it with a classical discriminator, and trains the adversarial pair to generate handwritten-digit-like images, with quantum gradients provided by PennyLane's autodifferentiation. It walks through the patched-generator construction, the adversarial training loop, and visualizing the images the quantum generator learns to produce. By bringing generative adversarial learning to quantum circuits, the demo is an engaging, applied example of generative quantum machine learning in PennyLane.
QML
Qubit
Circuit-based
Uploaded 3 days ago
12
Views
GitHub
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

https://github.com/PennyLaneAI/demos/blob/c52c0abeb5122218aa96b38eea848864cce7323f/demonstrations_v2/tutorial_quantum_gans/demo.py
README.md

Quantum GANs with PennyLane

This PennyLane demo implements a Quantum Generative Adversarial Network (QGAN), adapting the adversarial-training paradigm of classical GANs to quantum circuits to learn and generate data distributions. A GAN pits two networks against each other: a generator that learns to produce realistic samples and a discriminator that learns to distinguish real from generated data, with the two improving through competition. In this demo the generator is built from quantum circuits, specifically a patched approach where several sub-generator circuits each produce part of the output so that limited-qubit circuits can generate higher-dimensional data. The tutorial implements the quantum generator in PennyLane, wraps it for training with PyTorch, pairs it with a classical discriminator, and trains the adversarial pair to generate handwritten-digit-like images, with quantum gradients provided by PennyLane's autodifferentiation. It walks through the patched-generator construction, the adversarial training loop, and visualizing the images the quantum generator learns to produce. By bringing generative adversarial learning to quantum circuits, the demo is an engaging, applied example of generative quantum machine learning in PennyLane.

Run it

pip install -r requirements.txt
python demo.py

Source and license

Imported from demonstrations_v2/tutorial_quantum_gans/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 15, 2026
qcr:2606.36748.1

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

Tools used

PennyLane

Keywords

quantum-gan
generative
quantum-machine-learning
pennylane
pytorch

You may also like5