Adversarial Generative Models intermediate 7 min read 12 flashcards

The GAN Minimax Game

What the discriminator is actually estimating, why the theoretically clean generator loss cannot be used in practice, and what it means that training seeks an equilibrium rather than a minimum.

Every other generative model in this library optimises a loss. A GAN does not. Two networks optimise opposing objectives, and training succeeds when neither can improve, which is a Nash equilibrium rather than a minimum. That single structural difference explains most of what is strange about GANs: why the loss curve tells you nothing, why training diverges without warning, and why the field spent years on stabilisation tricks rather than on architecture.

The objective and what the discriminator learns

The original formulation (Goodfellow et al., 2014, arXiv:1406.2661) is

\[\min_G \max_D \ \mathbb{E}_{x \sim p_{\text{data}}}[\log D(x)] + \mathbb{E}_{z \sim p_z}[\log(1 - D(G(z)))]\]

For a fixed generator, the optimal discriminator has a closed form:

\[D^*(x) = \frac{p_{\text{data}}(x)}{p_{\text{data}}(x) + p_g(x)}\]

This is worth pausing on. The discriminator is not learning "what a real image looks like"; it is estimating a density ratio between the data distribution and the generator's distribution. Substituting \(D^*\) back into the objective shows the generator is minimising the Jensen-Shannon divergence between \(p_g\) and \(p_{\text{data}}\), up to a constant. The adversarial game is a way to estimate and descend a divergence without ever writing down either density.

Why nobody uses the loss as written

The generator term \(\log(1 - D(G(z)))\) is saturating. Early in training the generator is bad, the discriminator confidently outputs \(D(G(z)) \approx 0\), and the gradient of \(\log(1-D)\) at that point is nearly flat. The generator gets almost no signal exactly when it needs the most.

The fix, present in the original paper, is the non-saturating loss: instead of minimising \(\log(1 - D(G(z)))\), maximise \(\log D(G(z))\). The fixed points are the same, but the gradient is large when the discriminator is confident, so the generator learns fastest when it is worst. This is not the same objective, and it no longer corresponds exactly to minimising JS divergence, which is a good early example of a pattern that repeats throughout GAN practice: the theory motivates the design and the implementation deviates from it for optimisation reasons.

Equilibrium, not minimisation

In ordinary training, a falling loss means progress. In a GAN, the generator loss falling means the generator is currently beating the discriminator, which may mean the generator improved or may mean the discriminator got worse. The two are indistinguishable from the loss curves. A well-balanced GAN shows discriminator accuracy hovering near chance and both losses roughly flat, which looks exactly like a model that has stopped learning.

This is why GAN development depends on sample inspection and on separate metrics such as FID far more than other generative modelling does, and why "the loss went down" is not a report anyone experienced will accept.

When it breaks

The discriminator can win too hard. If the discriminator becomes perfect, its outputs saturate, gradients to the generator vanish, and training stops. If it is too weak, its density-ratio estimate is poor and the generator is chasing noise. The balance is maintained by hand through relative learning rates, update ratios, and capacity choices, and it is the reason GAN recipes are so specific and so brittle across datasets.

Non-convergence is a real dynamical behaviour, not just bad luck. The simultaneous gradient dynamics of a two-player game can cycle rather than converge, orbiting an equilibrium indefinitely. This is visible in low-dimensional toy problems and is the theoretical justification for regularisers such as the zero-centred gradient penalty and for optimiser modifications that damp the rotational component of the update.

Disjoint supports break the gradient before optimisation starts. When \(p_g\) and \(p_{\text{data}}\) have negligible overlap, which is the normal situation early in training on image data, JS divergence is constant at \(\log 2\) and its gradient is zero almost everywhere. Adding noise to both distributions, or switching to a divergence that behaves under disjoint support, is the direct response; the second is what Wasserstein GANs do.

The equilibrium is not unique. Nothing in the objective distinguishes a generator that covers the data distribution from one that covers a well-chosen subset, provided the discriminator cannot tell. This is the formal shape of mode collapse, and it explains why the phenomenon is a property of the objective rather than a symptom of insufficient training.

Check yourself

12 flashcards for this concept

Click a card to reveal the answer.

Drill the whole track