Generative Adversarial Networks
A generative adversarial network trains two networks against each other: a generator that turns noise into samples, and a discriminator that tries to tell real data from forgeries. The game has a clean theory: the optimal discriminator is a likelihood ratio, and at equilibrium the generator minimizes the Jensen–Shannon divergence to the data, with a global optimum exactly when its distribution matches the data.
╌╌╌╌
The variational autoencoder learns to generate by maximizing a likelihood bound; it pays for tractability with blurry samples, because a pixel-wise reconstruction loss favors averaged, hedged predictions. A generative adversarial network (GAN) discards the likelihood entirely and replaces it with a learned critic. Instead of scoring how probable an image is under the model, it trains the generator against a second network that tries to tell generated images from real ones, and the generator's goal is to make that network fail. There is no explicit density, no reconstruction term, only a game.1
The generator never sees the data. It only ever receives a gradient routed back through the discriminator, the single channel that carries any information about what real samples look like.
The minimax game
Write for the (unknown) data distribution and for the distribution of induced by pushing the noise prior through the generator. The discriminator should output near on real samples and near on fakes; the generator wants the opposite for its own outputs. Both goals are captured by a single value function, the binary cross-entropy of the discriminator's classification task:
The discriminator maximizes (push on real, on fake); the generator minimizes it (push ). The training objective is the saddle point:
The optimal discriminator
Fix the generator, hence fix , and solve the inner maximization over . This is a pointwise problem: is an expectation over of a function that depends on only through the scalar , so we can optimize the integrand at each independently.
The optimal discriminator is not a black box2 but a recognizable statistical object: a calibrated posterior probability. Where the two densities are equal it returns exactly — it has no information and guesses.
| Region | vs | Meaning | |
|---|---|---|---|
| data-dominated | confidently real | ||
| matched | indistinguishable | ||
| fake-dominated | confidently fake |
What the generator actually minimizes
Substitute back into to find the objective the generator faces once the discriminator is optimal. This is the central result of the GAN theory: the adversarial game reduces to a divergence between distributions.
At equilibrium the discriminator is reduced to a coin flip: it cannot do better than chance because the two distributions coincide. Compare the divergence GANs minimize against the one VAEs and likelihood models minimize: the asymmetry of the choice is the source of GANs' signature behavior.
| Objective | Divergence minimized | Behavior when misses a mode |
|---|---|---|
| maximum likelihood / VAE | heavily penalized — forces mass everywhere (mode covering) | |
| GAN (ideal) | symmetric, bounded — tolerates dropping modes (mode seeking) | |
| reverse KL | penalizes putting mass where data is absent |
The JSD is symmetric and bounded by , and that boundedness is what lets GANs produce sharp samples while quietly abandoning parts of the data, a trade we return to under mode collapse.3
A worked objective computation
For example, take a single point where the data density is and the generator's is . The optimal discriminator there is the likelihood ratio
It correctly leans toward real,
since data is four times as dense there. The
value-function integrand at (per unit of the two densities) is
Now step back to a whole toy distribution and compute the generator's true objective . Let both densities live on two points with
so the mixture is . The two KL divergences to the mixture are
So nats, and the generator's objective sits at
The floor is , reached only when . The generator is nats above the floor — a small, bounded gap, which is the whole point: even a fairly wrong generator ( versus on one atom) incurs only a modest JSD penalty. That boundedness is precisely why the generator can afford to sit on one mode, the seed of mode collapse.
The training dynamics
In practice we cannot reach before each generator step; that would require an inner optimization to convergence per outer step. GANs instead alternate a few discriminator gradient ascents with a generator gradient descent, keeping the two roughly in step. With discriminator updates per generator update (often ):
- 1initialize generator params and discriminator params
- 2repeat
- 3for steps dotrain the discriminator
- 4sample minibatch
- 5sample minibatch
- 6
- 7ascend: maximizes
- 8sample minibatch
- 9non-saturating loss
- 10ascend the surrogate
- 11until converged
- 12return
As training proceeds, is dragged toward and the discriminator's decision curve flattens from a confident step toward the constant — the visual signature of convergence in Goodfellow's original figure.
Why the original generator loss saturates
The minimax form has minimize . Early in training is weak, the discriminator confidently rejects every fake, and . Examine the gradient of that loss with respect to the discriminator output :
At this is , small. The function is flat near and only steepens as . So precisely when the generator is losing badly (and most needs a strong corrective signal) the gradient is weakest; the loss saturates. The fix is to give the generator a different objective with the same fixed point but a healthy gradient where it matters.
The non-saturating loss is what every practical GAN actually trains with. It no longer corresponds to a clean JSD minimization (it minimizes a different divergence combination), but it makes the early gradient usable, which matters far more than theoretical purity.4
Failure modes
GAN training is a search for a saddle point of a non-convex two-player game, not a descent to a minimum. There is no monotone objective whose decrease certifies progress, and three pathologies follow directly.
| Failure mode | Mechanism | Symptom | Cure |
|---|---|---|---|
| Mode collapse | maps many to few outputs that reliably fool | low sample diversity; whole modes missing | feature matching, minibatch discrimination, unrolled GAN |
| Vanishing gradients | wins early; on a flat loss region | stops improving | non-saturating loss; Wasserstein (WGAN) |
| Instability / oscillation | the saddle-point dynamics cycle instead of converging | losses oscillate; samples flicker | spectral normalization; two time-scale update (TTUR); gradient penalty |
Mode collapse
The JSD is mode-seeking: a generator that places all its mass on a single sharp mode of already achieves a low (though not optimal) divergence, because JSD does not heavily punish missing mass the way forward KL does. If the discriminator cannot momentarily distinguish a single perfectly-rendered mode from the data, the generator has every incentive to collapse onto it.5
Fixes that change the objective
The deepest fix is to replace the JSD with a divergence whose gradient is informative even when and have disjoint support, the regime where JSD is constant at and supplies no gradient at all.
| Cure | Acts on | Idea |
|---|---|---|
| Feature matching | generator loss | match statistics of an intermediate layer instead of its output, broadening coverage |
| Minibatch discrimination | discriminator | let see whole batches, so it can punish low diversity directly |
| Wasserstein (WGAN) | value function | swap JSD for earth-mover distance — gradients survive disjoint support |
| Spectral normalization | discriminator weights | bound the Lipschitz constant of , stabilizing the game |
| Two time-scale (TTUR) | learning rates | give and separate rates so the dynamics converge |
Latent structure
Because is a smooth, deterministic map from a low-dimensional noise space, the geometry of becomes a geometry of generated samples. Interpolating along a straight line between two noise vectors and produces a continuous morph between and , evidence that the generator has learned a meaningful manifold rather than memorizing examples.6
The GAN decade
Goodfellow's 2014 paper launched a fast-moving line of work, and a few landmarks explain why GANs dominated image synthesis until diffusion arrived.7
Architecture came first. The original GAN used fully connected nets on small images; the DCGAN established the convolutional recipe — strided convolutions, batch normalization, no pooling — that made GAN training reproducible and is the template Chollet's practical chapter follows.8 Scaling then came from progressive growing and StyleGAN, whose style-based generator gave the disentangled, editable latent space behind the photorealistic faces that made GANs famous.9
Theory chased the instability. The Wasserstein GAN reframed the objective around earth-mover distance so gradients survive disjoint support, and WGAN-GP replaced weight clipping with a gradient penalty to enforce the Lipschitz constraint cleanly.10 Spectral normalization bounded the discriminator's Lipschitz constant a different way, and the two time-scale update rule with the Fréchet Inception Distance gave the field both a stable training scheme and the sample-quality metric it had been missing.11
Conditioning made GANs practical. Conditional GANs feed a label to both networks; pix2pix and CycleGAN turned the framework into image-to-image translation, learning to map sketches to photos or horses to zebras — CycleGAN doing so without paired data, using a cycle-consistency loss in place of the pairing.12 These are the applications, not the theory, but they are why GANs left the lab.
The learned-critic idea outlived GANs' reign as the top image model: it survives as the perceptual and adversarial losses inside super-resolution networks, as the discriminator that sharpens VAE and diffusion decoders, and as the training signal in the codec models that compress the latents diffusion runs on.
Where GANs sit among generative models
GANs are one of four major families of deep generative model, and the four trade off along three axes: whether they offer a tractable likelihood, how good their samples look, and how stable they are to train. Each sibling lesson develops one column.
| Model | Tractable likelihood? | Sample quality | Training stability | Idea |
|---|---|---|---|---|
| VAE | lower bound (ELBO) | moderate (often blurry) | stable | maximize a variational bound |
| GAN | no | high (sharp) | unstable (adversarial) | fool a learned critic |
| Autoregressive | exact | high | stable | factorize |
| Normalizing flow | exact | moderate–high | stable | invertible map with tractable Jacobian |
The dividing line is the likelihood. Autoregressive models and flows compute exactly and train by maximum likelihood; VAEs settle for a bound; GANs abandon it entirely, gaining sharpness at the cost of a likelihood they can neither report nor optimize. The trade-off — no density, no easy evaluation, frequent training failures — yields the sharpest samples of any pre-diffusion family, and a learned latent space smooth enough to interpolate through.
Footnotes
- Goodfellow, Deep Learning, §20.10.4 — generative adversarial networks as a generator/discriminator game with no explicit density, only a learned critic supplying the gradient. ↩
- Goodfellow, Deep Learning, §20.10.4 — the optimal discriminator is the likelihood ratio , derived by pointwise maximization of the value function. ↩
- Goodfellow, Deep Learning, §20.10.4 / §3.13 — substituting reduces the game to ; the symmetric, bounded JSD explains GANs' mode-seeking behavior versus maximum likelihood's mode covering. ↩
- Goodfellow, Deep Learning, §20.10.4 — the saturating minimax generator loss and the non-saturating surrogate that keeps the gradient strong when the generator is losing. ↩
- Goodfellow, Deep Learning, §20.10.4 — mode collapse: the generator concentrating mass on a few modes that reliably fool the discriminator, and remedies such as minibatch features. ↩
- Chollet, Deep Learning with Python, §8.5 — a practical DCGAN, the alternating training loop, and latent-space interpolation as evidence of a learned manifold. ↩
- Goodfellow et al.,
Generative Adversarial Nets,
NeurIPS 2014 — the original GAN, the minimax value function, and the JSD equilibrium analysis. ↩ - Radford, Metz & Chintala,
Unsupervised Representation Learning with Deep Convolutional GANs
(DCGAN), ICLR 2016 — the convolutional architecture guidelines that stabilized GAN training. ↩ - Karras, Laine & Aila,
A Style-Based Generator Architecture for GANs
(StyleGAN), CVPR 2019, building on Karras et al.,Progressive Growing of GANs,
ICLR 2018 — style-based, disentangled latent control for photorealistic synthesis. ↩ - Arjovsky, Chintala & Bottou,
Wasserstein GAN,
ICML 2017, and Gulrajani et al.,Improved Training of Wasserstein GANs
(WGAN-GP), NeurIPS 2017 — earth-mover distance and the gradient penalty. ↩ - Miyato et al.,
Spectral Normalization for GANs,
ICLR 2018, and Heusel et al.,GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium,
NeurIPS 2017 — stabilization and the Fréchet Inception Distance. ↩ - Isola et al.,
Image-to-Image Translation with Conditional Adversarial Networks
(pix2pix), CVPR 2017, and Zhu et al.,Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
(CycleGAN), ICCV 2017. ↩
╌╌ END ╌╌