A GAN consists of two networks that are competing against each other.

They are linked together in a GAN:

The generative network is trying to fool the discriminative network into misclassifying “fake” (generated inputs). Meanwhile, the discriminative network is also learning how to classify inputs as real or fake: i.e., does it come from the dataset, or from the generative network?

outputs the probability that is from the real data:
creates an input sample from random noise with distribution :
The loss for the GAN has two parts:
- The first term minimizes with respect to to make the discriminator better at detecting real vs. fake. are real inputs, and the target for and for .
- The second term minimizes with respect to to make the generator better at producing fake inputs that look real to the discriminator.


Training the generator:
- generate a fake sample
- pass it through the discriminator
- measure loss against the label 1
- update the generator so that the discriminator becomes more likely to output “real”.