Two networks with opposite objectives
- : the discriminator, which outputs the probability that its input is real.
- : the generator, which maps noise to a sample.
The discriminator maximises that expression by telling real from fake. The generator minimises it by producing samples the discriminator calls real.
There is no reconstruction term and no likelihood. The only signal the generator ever receives is the discriminator's opinion.
The optimum, and what it says
For a fixed generator, the best discriminator is that ratio, which is 0.5 everywhere when the two distributions match.
Substituting it back shows the generator is minimising the Jensen-Shannon divergence, so the objective is a divergence between distributions in disguise.
That is the theoretical result, and it assumes the discriminator is trained to optimality at every step, which it never is.
The gradient problem at the start
Early in training the discriminator wins easily, and the generator's gradient vanishes exactly when it needs the most guidance.
The non-saturating loss flips the objective to maximising the log of being called real, which has the same fixed point and a strong gradient when the generator is losing.
Every implementation uses this version. The minimax form in the paper is the analysis, not the code.
One training step, in order
- Sample a batch of real data and a batch of noise.
- Generate fakes and update the discriminator on both, with real labelled 1 and fake 0.
- Sample fresh noise and generate again.
- Update the generator through the discriminator, with the fakes labelled 1.
- Keep the two updates balanced, since either network winning outright stalls the other.
The discriminator's weights are frozen during step four. The gradient passes through it to reach the generator, and updating it there would be training it to be wrong.
Why it is hard to train
There is no convergence guarantee.
This is a two-player game rather than a minimisation, so the parameters can cycle indefinitely without either player improving.
Mode collapse is the characteristic failure: the generator finds a handful of outputs that fool the discriminator and stops producing anything else.
The loss values say almost nothing about sample quality, which is why GAN papers report FID and show images rather than plotting a curve.
Wasserstein GAN replaces the divergence with the earth mover's distance and constrains the discriminator to be Lipschitz.
That gives a loss which correlates with sample quality and a gradient that does not vanish.
Diffusion models displaced GANs for image generation largely because they train by a stable regression objective.
They pay for it in sampling, needing many forward passes to produce one image where a GAN needs one.