Adversarial Training and the Min-Max Objective

The Adversarial Dance

The two models are trained together in a zero-sum game:

  • When the discriminator correctly identifies a generated sample as fake, the generator is penalized.
  • When the generator fools the discriminator into thinking a fake is real, the discriminator is penalized.

At the theoretical limit, the generator produces perfect replicas of the input domain every time, the discriminator cannot tell the difference, and it predicts "50% real, 50% fake" on every sample. It has literally lost the ability to distinguish.

In practice, we train alternately in mini-batches: freeze the generator, train the discriminator; then freeze the discriminator, train the generator. Each iteration:

  1. The generator produces fake samples.
  2. The discriminator is fed a mix of real and fake samples with labels.
  3. The discriminator adjusts its weights to maximize the probability of correctly classifying real vs. fake.
  4. The generator adjusts its weights to minimize the probability that the discriminator identifies its outputs as fake.

The Min-Max Objective

The original objective from Goodfellow et al. (2014) is a min-max game. Let G be the generator, D the discriminator, x a real sample, and z the noise input. Then:

  • D(x)D(x) is the discriminator's estimated probability that x is real.
  • G(z)G(z) is the generator's output when given noise z.
  • D(G(z))D(G(z)) is the discriminator's probability that the generated sample is real.
minGmaxD  Expdata[logD(x)]+Ezpz[log(1D(G(z)))]\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)))]

The discriminator wants to maximize D(x)D(x) and minimize D(G(z))D(G(z)). The generator wants to maximize D(G(z))D(G(z)) — that is, fool the discriminator into thinking its output is real.

GAN Training — Step Through the Adversarial Loop1 / 5
Setup

Initialization

Both the generator G and discriminator D start with random weights. G produces pure noise-like outputs. D makes random 50/50 predictions. Neither network can do its job yet.

Discriminator loss

≈ 0.69

Random guessing — log(0.5) + log(0.5) ≈ −1.39

Generator loss

≈ 0.69

Generator output is noise — fooling no one

Generator output quality2%
Discriminator accuracy50%

Key insight

Both losses start near ln(2) ≈ 0.69, the entropy of a fair coin flip.

Step through one complete GAN training iteration: watch the discriminator update, then the generator update, and see how the loss surfaces evolve.

Training pathologies

This elegant formulation causes a lot of real problems in practice:

  • Vanishing gradients. If the discriminator becomes too good too fast, the generator stops getting meaningful gradients and can't learn.
  • Mode collapse. The generator may discover one or two outputs that reliably fool the discriminator and just produce those over and over, losing all diversity.
  • Training instability. The adversarial dynamic is fundamentally unstable. Models can oscillate, diverge, or simply fail to converge.

This led to a whole zoo of GAN variants with modified loss functions: WGAN (Wasserstein distance), LSGAN (least squares / MSE), BEGAN (autoencoder-based loss), and many more. The choice of loss function is enormously important.

Checkpoint

During GAN training, the discriminator's loss reaches near zero — it perfectly identifies every generated image as fake. What is the most likely consequence for generator training?