# Objective function of Quantum GAN in the paper "Quantum generative adversarial networks"

In this paper about Quantum GANs, the authors do not explain clearly how do they have the equation

$$\newcommand{\tr}{\operatorname{Tr}}\newcommand{\Pr}{\operatorname{Pr}} V(\vec{\theta}_D, \vec{\theta}_G)= \frac{1}{2}+\frac{1}{2\Lambda} \sum_{\lambda=1}^{\Lambda} \left[ \cos^2(\phi)\tr(Z\rho_\lambda^{DR}(\vec{\theta_R}))-\sin^2(\phi)\tr(Z\rho_\lambda^{DG}(\vec{\theta_R},\vec{\theta_D,z})) \right],$$

from

$$V(\vec{\theta}_D, \vec{\theta}_D)= \frac{1}{\Lambda} \sum_{\lambda=1}^{\Lambda} \Pr\Big[ ( D(\vec{\theta}_D,|\lambda\rangle, R(|\lambda\rangle)) = |\operatorname{real}\rangle ) \\\cap ( D(\vec{\theta}_D,|\lambda\rangle, G(\vec{\theta}_G,|\lambda,z\rangle)) =|\operatorname{fake}\rangle ) \Big] .$$

They suggested that it relate to classical case, but I still don't know the key point.

Hope to see some ideas from you. Thanks!

I am the first author of the paper and I have been asked this question more than once, so it’s worth answering here for further reference.

Keep in mind that the goal of the paper is to describe a variational construction of GANs such that it is compatible with NISQ devices. Hence the procedure must be differentiable and start from an expectation value formulation. In this picture, Eq. 12 of the paper is really the starting point of the derivation (it evolved from a generalization of the swap test procedure). The differentiable construction makes the training procedure (Eq. 13) and the fixed-point and limit cases analysis (Eq. 14-17) easy to perform.

From there, we retrofitted a corresponding classical interpretation that matches the essence of the original GAN paper, which is a classification problem for the discriminator and uses log probabilities (which is not necessary but generally makes training faster).

In essence, we want to maximize the probability that the discriminator $$D$$ outputs the state $$\left|\textrm{Real}\right\rangle$$ on training data $$R$$ and $$\left|\textrm{Fake}\right\rangle$$ when given a state from the generator $$G$$. This roughly matches the interpretation of the optimization problem over the constructed $$\left\langle Z\right\rangle$$ expectation value. In hindsight, it would have made more sense to use the union operator $$\cup$$ in Eq. 3 instead of the intersection operator $$\cap$$. It might also have been worth to comment that we did not use log probabilities (which would be interesting to do along with an analysis of the sampling complexity).

Additionally, the “$$\phi$$” terms of Eq. 11 may be somewhat confusing. This relative frequency is a free parameter in the construction. I presumed the cost function should be normalized over the relative frequency using the training data $$R$$ and using the generator $$G$$. This is an artefact of an earlier derivation where $$R$$ and $$G$$ were inputs on different channels of $$D$$ and the which-path information had to be erased. Leaving it in the single channel formulation has the advantage of preventing pathological cases where the cost function would only be measured on $$R$$ (or $$G$$). As told in the main text, the simple case where $$R$$ and $$G$$ are picked at random corresponds to $$\phi = \frac{\pi}{4}$$.