4.5.8 · D4Generative Models

Exercises — GAN training instability and mode collapse

2,025 words9 min readBack to topic

This page is a self-test ladder. Work each problem before opening its solution. The rungs climb from recognition (can you name it?) to mastery (can you build the fix?). Every notation used here is earned in the parent note; if a symbol feels unfamiliar, re-read the parent first.

Quick reminder of the cast of symbols (all from the parent):

  • ::: discriminator's probability that is real, a number in .
  • ::: a fake sample the generator builds from noise .
  • ::: the real data distribution and the generator's distribution.
  • ::: the WGAN critic, a plain real number (no squashing into ).

Level 1 — Recognition

Exercise 1.1

A generator on MNIST outputs only the digit "3", every single time, and its loss stays low. Name the failure mode and state the one-sentence reason it is stable for the generator.

Recall Solution

This is mode collapse. It is stable because the generator's objective only rewards fooling the discriminator right now; producing one "safe" output that reliably fools gives low loss, and there is no term in that rewards variety across the distribution.

Exercise 1.2

Two students describe GAN failures. Student A: "The loss curves swing up and down and never settle." Student B: "The samples all look identical." Label each with the correct term: training instability or mode collapse.

Recall Solution
  • Student A → training instability (oscillation / non-convergence).
  • Student B → mode collapse (limited variety).

Exercise 1.3

True or false: In the non-saturating loss, the generator minimizes . Explain in one line.

Recall Solution

False. The original loss minimizes . The non-saturating fix has the generator maximize instead — same fixed points, stronger early gradients.


Level 2 — Application

Exercise 2.1

The optimal discriminator is . At a point , and . Compute .

Recall Solution

The discriminator is 75% sure this point is real — sensible, since real density is 3× the fake density here.

Exercise 2.2

A sample fools with . Compute the generator's loss (natural log). Then compute it for a new mode with . Which is larger, and by roughly what factor?

Recall Solution

The new-mode loss is larger by a factor . The generator is ~11× more penalized for exploring — this is the numerical heart of mode collapse.

Exercise 2.3

For a perfect generator, everywhere. Show and state what this means physically.

Recall Solution

The best possible discriminator is reduced to a coin flip — it cannot distinguish real from fake, which is exactly the equilibrium we want.


Level 3 — Analysis

Exercise 3.1

The generator's gradient contains the product A student says "when is confident, , so the scalar is small." Diagnose the error and identify the true cause of the vanishing gradient. Use the figure.

Figure — GAN training instability and mode collapse
Recall Solution

The student is wrong: at the scalar is a constant of magnitude 1, not small. Look at the blue sigmoid curve in the figure: a confident discriminator lives on the flat tails near output or . Flat means slope , i.e. . The pink arrows show the slope shrinking to nothing on the tail. So the product dies because of the saturated input-gradient, not the scalar. The non-saturating loss swaps the scalar for , which blows up as and rescues the signal.

Exercise 3.2

Explain why the discriminator "forgetting" old modes (the MNIST 1→7→1 oscillation) is a consequence of only summing over currently produced fakes.

Recall Solution

. The second term only contains samples actually produces now. If stops making "1"s and makes "7"s, the gradient pushing to catch "1"s disappears; 's decision boundary drifts toward catching "7"s and un-learns "1". When swings back to "1", it faces a that has forgotten it — low loss again. There is no memory term, so the cycle self-perpetuates.

Exercise 3.3

In the non-saturating loss the scalar prefactor is . Evaluate it at and at . Explain why the large early value is a feature, not a bug.

Recall Solution

At : . At : . Early in training is confident about fakes, so is tiny and the prefactor is huge. This large number amplifies the small saturated , restoring a usable learning signal exactly when the original loss had none. As improves () the prefactor calmly relaxes to . So the "explosion" is self-limiting and targeted.


Level 4 — Synthesis

Exercise 4.1

WGAN replaces with a critic producing a real number and minimizes generator loss . Explain, combining two ideas from the parent, why this simultaneously fixes (a) vanishing gradients and (b) mode collapse.

Recall Solution

(a) Vanishing gradients: the critic has no sigmoid, so it never saturates onto a flat tail; stays non-zero everywhere. The signal that the saturated destroyed can no longer die. (b) Mode collapse: the Wasserstein distance measures the cost of transporting mass across all of space. A missing mode leaves probability mass un-transported, which the sup detects and penalizes — so the gradient pulls toward every mode, not just the visible ones. Synthesis: (a) is a property of the critic's output shape; (b) is a property of the distance being optimized. WGAN changes both at once.

Exercise 4.2

A critic is 1-Lipschitz, meaning for all points. If two samples are distance apart, what is the maximum possible difference in critic scores? Why does bounding this matter for stable training?

Recall Solution

Maximum difference . The Lipschitz cap limits how steep the critic can be, so can never blow up to arbitrarily large values. This keeps the generator's gradient bounded and well-conditioned — the objective now correlates smoothly with sample quality instead of spiking. Enforced by weight clipping or a gradient penalty.

Exercise 4.3

Combine Exercises 2.2 and 3.2: in one paragraph, trace the causal chain from "generator's per-mode loss is asymmetric" to "discriminator forgets modes" to "oscillation."

Recall Solution

From 2.2, exploring a fresh mode costs ~11× the loss of repeating a safe one, so greedily collapses onto the safe mode. From 3.2, only trains against modes currently produces, so specializes on the safe mode and its boundary drifts, forgetting others. Once over-specializes, a different safe mode becomes cheap for , so jumps to it; chases, forgetting the first; when returns, the first mode is cheap again. The asymmetric incentive plus the memoryless produce a limit cycle — the 1→7→1 oscillation.


Level 5 — Mastery

Exercise 5.1

Derive the optimal discriminator. Starting from the fixed- objective treat the integrand pointwise as with , and maximize over .

Recall Solution

Differentiate: . Set to zero: Substituting back, . Second derivative , confirming a maximum. This is exactly the parent's result, now derived from scratch.

Exercise 5.2

Prove the equilibrium value. Plug (perfect generator, ) into the original objective and show the game value equals (natural log). Interpret it.

Recall Solution

With , everywhere, so Numerically . Interpretation: at the global optimum the value is a fixed constant ; the generator cannot push it lower because it has already matched perfectly. This is the theoretical "convergence target."

Exercise 5.3

Design task. You observe: (i) reaches ~99% accuracy in 50 steps and 's samples freeze; (ii) samples show only 2 of 10 MNIST classes. Prescribe two concrete interventions from the vault, name the exact mechanism each repairs, and predict the observable change.

Recall Solution

Intervention 1 — Non-saturating loss (maximize ). Mechanism repaired: the saturated input-gradient from symptom (i). The prefactor amplifies the tiny gradient. Predicted change: 's loss starts moving again; samples un-freeze. Intervention 2 — Switch to WGAN critic + Lipschitz constraint (see 4.5.07-Wasserstein-GAN-and-improved-training). Mechanism repaired: (a) removes sigmoid saturation entirely; (b) the Wasserstein distance pulls toward all modes, fixing the 2-of-10 collapse in symptom (ii). Predicted change: sample variety climbs toward all 10 digits; loss now tracks quality. (Optional third: balance update ratio / lower 's learning rate — see 3.4.05-Optimization-challenges-in-deep-learning — to stop winning in 50 steps. Also 4.3.06-Batch-normalization-and-alternatives can stabilize the training dynamics.)


Recall Self-check ledger (open only after attempting all)

Which term is a constant , not small, when ? ::: the original-loss scalar . What actually vanishes to kill the gradient? ::: the input-gradient , because a confident saturates onto a flat tail. Global game value at optimum (natural log)? ::: . Ratio of new-mode loss to safe-mode loss in Ex 2.2? ::: about .

Related: 4.5.01-Generative-Adversarial-Networks-fundamentals · 4.5.09-StyleGAN-and-progressive-growing · 4.5.10-Conditional-GANs-and-control