Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.When the forger learns only one trick
A GAN trains a forger (the generator) against a detective (the discriminator). If the forger finds one kind of fake that fools the detective, it is tempted to produce only that kind. That is mode collapse: a face generator that draws the same few faces, or a terrain generator that only makes deserts. Training can also wobble forever, because each player keeps reacting to the other. Stabilisation tricks either give the detective a way to notice a lack of variety or keep the game from swinging too hard. The demo shows how little some divergences charge a generator for dropping whole modes.
Generative models make synthetic sensor data for rare events (failures, extreme weather, unusual terrain). A collapsed generator silently produces only the common cases, which is exactly the opposite of what testing needs. Coverage must be measured, not assumed.
- 1. Mode collapse means the generator…
- 2. GAN training is…
- 3. Minibatch standard deviation lets D see…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Failure modes. Mode collapse (Goodfellow 2016 tutorial; many generator inputs map to the same output); mode hopping, where G jumps from mode to mode as D catches up (Metz et al. 2017, unrolled GANs); non-convergence and oscillation, since simultaneous gradient descent circles around game equilibria (Mescheder et al. 2018); vanishing gradients with a saturated D (Arjovsky and Bottou 2017).
- Why collapse is cheap. If G covers k of n equal modes, the Jensen–Shannon divergence is at most ln 2 and only 0.216 nats for k = 4, n = 8, and the reverse KL is ln(n/k). Forward KL (maximum likelihood) would be infinite, which is why likelihood models rarely drop modes.
- Seeing variety. Feature matching and minibatch discrimination (Salimans et al. 2016); minibatch standard deviation, one extra feature in D (Karras et al. 2018, ProGAN); PacGAN, D sees packs of samples (Lin et al. 2018).
- Smoothing D. One-sided label smoothing (Salimans 2016); instance noise (Sønderby et al. 2017); WGAN-GP gradient penalty (Gulrajani et al. 2017); R1 penalty on real data (Mescheder et al. 2018), standard in StyleGAN; spectral normalisation (Miyato et al. 2018), standard in BigGAN and SAGAN.
- Optimisation. Adam with β1 = 0 or 0.5; two-time-scale update rule, TTUR (Heusel et al. 2017), proven to converge to a local Nash equilibrium; extra D steps per G step; EMA of G weights for evaluation (Karras 2018; Yazıcı et al. 2019).
- Little data. Adaptive discriminator augmentation, ADA (Karras et al. 2020) and DiffAugment (Zhao et al. 2020) stop D from memorising small datasets.
- 2024 recipe. R3GAN (Huang et al., NeurIPS 2024) shows that a relativistic pairing loss with R1 and R2 penalties trains stably without most older tricks.
- 1. TTUR uses…
- 2. R1 penalises…
- 3. ADA helps when…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Diagnosing and stabilising GANs
Exercise 1.
- The minibatch standard-deviation feature.
- Jensen–Shannon divergence between discrete distributions.
- EMA of generator weights.
- Spectral norm by power iteration.
Practice.
- Monitor coverage, not only the loss: GAN losses do not track sample quality. Track FID and precision/recall every few thousand steps on a fixed set of latents.
- Start from a known-good recipe: StyleGAN2-ADA or R3GAN for images; spectral norm in D plus hinge loss for conditional models.
- Penalise D: R1 with γ tuned to resolution (StyleGAN2 uses γ from about 0.01 to 10).
- Average G: evaluate an EMA copy of the generator; it is smoother and usually scores better.
- Small data: turn on ADA or DiffAugment before anything else.
- Collapse alarm: many near-identical samples, or one class dominating, means G has outpaced D. Lower G’s learning rate or strengthen D.
import torch, torch.nn as nn
D = nn.Sequential(nn.utils.spectral_norm(nn.Linear(2, 128)), nn.LeakyReLU(0.2),
nn.utils.spectral_norm(nn.Linear(128, 1)))
def r1_penalty(D, x_real, gamma=10.0):
x_real.requires_grad_(True)
g, = torch.autograd.grad(D(x_real).sum(), x_real, create_graph=True)
return gamma / 2 * g.pow(2).sum(1).mean()
optD = torch.optim.Adam(D.parameters(), lr=4e-4, betas=(0.0, 0.99)) # TTUR: D faster than G
optG_lr = 1e-4- 1. GAN losses are…
- 2. Evaluate an EMA copy of…
- 3. For small datasets turn on…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why collapse is an equilibrium of the wrong game. For a fixed D, the generator’s best response puts all its mass on the single point x* that maximises D(x). It is a delta function, not a distribution. Only the alternation with D pushes it away. If G moves faster than D adapts, G hops from one maximiser to the next and never spreads out.
Cheap mode dropping. With n equal modes and a generator spread equally over k of them, JS(p, q) is finite (0.497 nats for k = 1, n = 8) and reverse KL(q‖p) = ln(n/k). Neither ever becomes infinite, so the training signal for a missing mode is weak.
Gradient penalties and convergence. Mescheder et al. (2018) analysed the Dirac-GAN: one data point at 0, a generator at θ and a linear discriminator ψx. Plain simultaneous gradient descent circles around (0, 0) and never settles. With R1 = γ/2 · E‖∇D‖² on real data, the Jacobian’s eigenvalues get negative real parts and training converges locally.
Minibatch statistics. A per-sample discriminator cannot tell whether a batch is too uniform; every single fake may look real. Giving D the batch’s standard deviation makes a lack of variety detectable, and G receives a gradient that pushes samples apart.
- 1. For a fixed D, G's best response is…
- 2. Plain gradient descent on the Dirac-GAN…
- 3. A per-sample D cannot detect…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Which stabilisation choices actually prevent mode collapse on the ring of 8 Gaussians?
History.
- I. Goodfellow, “NIPS 2016 tutorial: generative adversarial networks” (2016); T. Salimans et al., “Improved techniques for training GANs” (2016).
- L. Metz et al., “Unrolled generative adversarial networks” (2017), which introduced the ring-of-Gaussians test.
- M. Heusel et al., TTUR and FID (2017); T. Karras et al., ProGAN (2018); L. Mescheder et al., “Which training methods for GANs do actually converge?” (2018).
Exercise 2. One setup, four variants.
- Data and models: 8 Gaussian modes (sd 0.1) on a circle of radius 2. G: 4-dimensional noise → 32 → 32 → 2. D: 2 → 32 → 32 → 1 (leaky ReLU). Non-saturating loss, Adam (β1 = 0.5), batch 64, 650 steps.
- Variants: plain (both learning rates 0.002); minibatch standard deviation appended to D’s input; D 4× faster (0.008, TTUR); G 4× faster.
- Metrics: quality = share of 2000 samples within 0.4 of a mode. A mode counts as covered if it holds at least 20% of its fair share, 50 samples. Top-mode share = fraction of good samples in the most popular mode (0.125 if balanced).
| variant (seed 0) | modes covered | quality | top-mode share |
|---|---|---|---|
| plain GAN | 1 | 0.143 | 0.22 |
| minibatch std | 8 | 0.455 | 0.167 |
| D 4× faster | 5 | 0.27 | 0.265 |
| G 4× faster | 3 | 0.136 | 0.397 |
- The plain GAN did not collapse; it smeared. Its samples formed a blurry ring between modes (quality 0.13–0.15 on all seeds, top share about 0.2). After 650 steps it was undertrained, not collapsed.
- Minibatch std was the clear winner: 8 of 8 modes on every seed (quality 0.455, 0.374, 0.399).
- TTUR helped but varied: 5, 4 and 7 modes on seeds 0, 1 and 2.
- A faster generator collapsed: 3, 1 and 2 modes, with the top mode holding 0.397, 0.567 and 0.598 of good samples. This is the failure that TTUR’s direction (D faster) guards against.
- Seeds 1 and 2: plain 2 and 0 modes (quality 0.151, 0.127); minibatch std 8 and 8.
- Caveat: a 2D toy with a short budget. R1, spectral norm and EMA are built in the exercises but were not compared here.
Mode collapse in AI, robotics and aerospace
- Synthetic training data: collapsed generators under-represent rare classes. Check per-class coverage before using GAN data to train detectors (for example rare aircraft types in satellite images).
- Scenario generation: adversarial scenario generators for autonomous-vehicle testing must keep diversity, or they rediscover the same failure again and again.
- Diffusion models largely replaced GANs for images partly because likelihood-style training does not drop modes. GANs remain in use where one-step sampling matters (super-resolution, distillation of diffusion models, real-time graphics).
References
- T. Salimans et al. (2016). “Improved techniques for training GANs.” NeurIPS.
- L. Metz, B. Poole, D. Pfau and J. Sohl-Dickstein (2017). “Unrolled generative adversarial networks.” ICLR.
- M. Heusel et al. (2017). “GANs trained by a two time-scale update rule converge to a local Nash equilibrium.” NeurIPS.
- L. Mescheder, A. Geiger and S. Nowozin (2018). “Which training methods for GANs do actually converge?” ICML.
- T. Miyato et al. (2018). “Spectral normalization for generative adversarial networks.” ICLR.
- T. Karras et al. (2020). “Training generative adversarial networks with limited data.” NeurIPS.
- Y. Huang et al. (2024). “The GAN is dead; long live the GAN! A modern GAN baseline.” NeurIPS.