Introduction

Since Alex Krizhevsky’s breakthrough in imagenet competition, deep learning has been transforming the way we process large scale complex data with computers. Deep neural networks can perform image and speech recognition at very high accuracies. One of the exciting developments in deep learning is generative adversarial networks- GANs which have many applications: image generation, generation of 3d objects, text generation, generation of synthetic data for chemistry, biology and physics.

Quantum GANs which use a quantum generator or discriminator or both is an algorithm of similar architecture developed to run on Quantum systems. The quantum advantage of various algorithms is impeded by the assumption that data can be loaded to quantum states. However this can be achieved for specific but not generic data.

Data loading can easily dominate the overall complexity of an otherwise advantageous quantum algorithm in many cases with complexity O(2n). A variant of QGAN with a quantum generator and classical discriminator can be used to efficiently load data into quantum states in O(poly(n)) time. Here we discuss GANs and QGANs and how they are similar and the quantum processing associated with it. Let’s delve into a primer on classical GAN.

Classical GANs

Generative – Learning a generative model

Adversarial – Training in an adversarial setting

Networks – Using Deep Neural Networks

A deep generative model with two networks- Generator and Discriminator that compete with each other in a game.

Generator – generates images from random noise and tries to fool discriminator

Discriminator – tries to classify generated images and real images more accurately

Training is complete when the system achieves equilibrium.

GAN Architecture

Probabilistic interpretation of GANs

Suppose the real-world data comes from some fixed distribution pR(x), generated by some (potentially complex and unknown) process R. The generator – parameterized by a vector of real-valued parameters θ – takes as input an unstructured random variable z (typically drawn from a normal or uniform distribution). G transforms this noise source into data samples x = G(θ, z), creating the generator distribution pG(x). In the ideal case of a perfectly trained generator G, the discriminator would not be able to decide whether a given sample x came from pG(x) or from pR(x) . Therefore, the task of training G corresponds to the task of maximizing the probability that D misclassifies a generated sample as an element of the real data. On the other hand, the discriminator – parameterized by a vector of real-valued parameters φ – takes as input either real data examples x ∼ pR(x) or fake data samples x ∼ pG(x). D’s goal is to discriminate between these two classes, outputting a binary random variable. Training D thus corresponds to maximizing the probability of successfully classifying real data, while minimizing the probability of misclassifying fake data.

The optimization problem turns out to be min-max optimization problem with θ , φ as parameters and various optimization algorithms like ADAM and AMSGRAD are typically chosen to solve the optimization objective

If you want to dig deeper into the math of GAN, here’s the mathematical model.

GAN mathematical model:

X = { x0, . . . , xs−1 } ⊂ Rkout Sampled from pR(x)

Gθ: Rkin → Rkout θ ∈ Rkg

Dφ: Rkout → {0,1} φ ∈ Rkd

Generator loss function:

LG (φ, θ) = −Ez∼prior [log (Dφ (Gθ (z)))] =

Discriminator loss function:

LD (φ, θ) = Ex∼preal [log Dφ (x)] + Ez∼prior [log (1 − Dφ (Gθ (z)))] =

Training GAN is equivalent to searching Nash- equilibrium

Max LG (φ, θ)

Max LD (φ, θ)

Quantum GANs – overview

We can generalize these ideas of GAN to quantum setting. QGANs can be formulated in several ways. They can be modeled with both generator and discriminator on quantum systems where data takes the form of an ensemble of quantum states. Another model of QGAN where the generator is classical, can theoretically generate real data by fixed measurement on a fault tolerant system which can be considered quantum supremacy.

In this blog we discuss a variant of QGAN where the generator is quantum and the discriminator is classical which captures the probability distribution of classical training samples. We shall look at specifically how QGAN can be implemented to load distribution data in polynomial time into quantum states.

QGANS for learning and loading random distributions

Quantum algorithms have the potential to outperform classical counterparts but loading classical data into quantum states requires O(2n) for the best known methods thus impairing the potential quantum advantage in many cases.

A hybrid quantum classical algorithm(HQC) – QGAN can facilitate efficient loading of generic probability distributions in O(poly(n))

This can help in using classical data to do quantum information processing efficiently for tasks using the quantum generated data from QGAN to apply other quantum algorithms like Quantum amplitude estimation(QAE) which has applications in finance domain etc

This model of QGAN uses:

Data (Classical)

Generator (Quantum)

Discriminator (Classical)

A variational quantum circuit is used as generator and a neural network as a discriminator. Classical data is loaded into quantum states using this architecture which can be used on other quantum algorithms like QAE.

QGANS – Quantum generator

A parametrized quantum channel, i.e. the quantum generator, is trained to transform a given n-qubit input state |ψin⟩ to an n-qubit output state.

where pθj describe the resulting occurrence probabilities of the basis states |j⟩

Quantum generator is implemented by a variational quantum circuit consisting of alternating layers of single qubit rotations(pauli y (Ry) rotations) and blocks of two two qubit gates(controlled z gates(Cz))

Carefully chosen input state can help reduce complexity of generator and faster convergence. Preparation of input state should be O(poly(n)) to not impair speed advantage.

Quantum circuit:

The variational form, depicted in (a), with depth k acts on n qubits. It is composed of k + 1 layers of single-qubit Pauli-Y -rotations and k entangling blocks Uent. As illustrated in (b), each entangling block applies CZ gates from qubit i to qubit (i + 1) mod n, i ∈ { 0, . . . , n − 1 } to create entanglement between the different qubits.

QGANS – Architecture

QGANS – Optimisation and learning

Classical discriminator is a standard neural network with sigmoid activation functions

Given m data samples gL from quantum generator and m randomly chosen data samples from real data samples xL where L = 1,2,..m, the loss functions of QGAN are

Generator loss:

Discriminator loss:

As in the classical case, the loss functions are optimized alternately w.r.t θ and φ

QGANS – Simulation study

As explained in earlier blog, we use the Qiskit library on IBM Q experience. QGAN implementation can be done by a variational quantum circuit for the generator which was built in qiskit. We use this framework to generate log-normal distribution using quantum generators and classical discriminator.

We build a quantum circuit using 2 qubits and use samples from log normal distribution as real data. Using either a back-end or a simulator to run, QGAN can be initialized in the following manner:

The numpy discriminator is a classical 3 layer neural network that uses linear transformation, leaky relu in hidden layer and sigmoid in output layer. The default method of optimization of parameters is ADAM.

We printed loss functions of generator and discriminator to observe convergence.

Relative entropy plot after running the QGAN: If P is the actual distribution taken and Q is the generated distribution, the closeness of the two distributions can be measured by relative entropy given by:

Cdf plot of log normal vs the simulated points:

Conclusion and Outlook

Using QGANs we can load random probability distributions into quantum data states efficiently in polynomial time and this quantum generated data can be used on other quantum algorithms like QAE for use cases in the banking and financial industry. The probability distribution for Initialisation of the generator needs to be carefully selected for the QGAN to perform optimally. Further studies of performance on various distributions have been published to show the efficacy of QGAN in the research with application in quantum finance.

References

Note: There may have been some structural changes in the github code from when we explored it.

About the Authors

Aniruddh Rawat is a Data Scientist at Sigmoid. He works with data and application of Machine Learning algorithms. Currently, he is focusing on Quantum Machine Learning, Recommendation Systems and Big Data architecture.

Assisted by – Bhaskar Ammu – A Senior Data Scientist at Sigmoid. He leads a team of data scientists and specializes in designing data science solutions for businesses, building database architectures, and managing projects.

Sign up for the free insideBIGDATA newsletter.

Join us on Twitter: @InsideBigData1 – https://twitter.com/InsideBigData1

Source: https://insidebigdata.com/2021/05/27/quantum-machine-learning-an-introduction-to-qgans/