GAN training: rotation, saturation and missing modes
GAN 训练与模式坍塌
Separate optimization instability from mode coverage using exact games and finite-mode diagnostics.
gan-trainingBoth players improve, yet the pair goes nowhere
Imagine two sliders, θ and ψ. One player lowers their product; the other raises it. Each uses the correct gradient, but the target changes whenever the other slider moves. Unlike minimizing one shared loss, making a good local move for each player need not bring the pair closer to equilibrium.
GAN training has several distinct problems: rotational dynamics, weak generator gradients, and insufficient coverage of the data distribution. Calling all of them “instability” hides which intervention could help. The original GAN paper discusses non-saturating gradients and the need to synchronize the players; Mescheder and colleagues analyze nonconvergence and regularization in simple games. This article builds on GAN objectives and uses exact teaching examples to separate the mechanisms.
A small game with an exact answer
Our optimization model is the bilinear game below. θ is the minimizing player’s scalar parameter; ψ belongs to the maximizing player. It is related to the rotational behavior in the paper’s Dirac-GAN, but is not a complete image GAN or all of that paper’s nonlinear objectives.
The equilibrium is (0,0). In continuous time, the derivative of θ²+ψ² is zero: the two cross terms cancel. Nonzero initial states rotate instead of approaching the equilibrium. Now ask what a finite learning rate does.
Three update rules, three behaviors
Simultaneous updates evaluate both gradients at the old pair. With learning rate η, the matrix M satisfies a simple norm identity:
Thus every nonzero state’s squared radius grows by 1+η² per update. Even an arbitrarily small fixed positive step produces outward drift over enough iterations. Correct individual gradients have not made a descent method for distance to the equilibrium.
Alternating updates first move θ, then use the new θ to update ψ. Its determinant is one. For 0<η<2, it preserves a positive quadratic form rather than contracting it:
Bounded oscillation is an improvement over outward drift, but it is not convergence. For steps above two, this alternating method can itself be unstable. The distinction matters when inspecting a training trace that appears to have “settled into a range.”
Add a zero-centered quadratic penalty to the maximizing player’s objective, leaving the minimizing player’s derivative unchanged. This produces damping:
For γ=1 and η=0.1, the discrete eigenvalues have magnitude sqrt(0.91), below one. The state contracts asymptotically; its Euclidean norm need not decrease at every single step. Large learning rates can still fail. Section 3.3 of the convergence paper derives a related zero-centered penalty for its Dirac-GAN and explicitly qualifies convergence by sufficiently small steps. This is not a global guarantee for arbitrary neural networks.
For a fake sample with logit t, the original generator losses expose another mechanism. Differentiate them before applying the rest of the network’s chain rule:
At t=−12, the minimax derivative has magnitude about 0.000006144, whereas the non-saturating derivative is about 0.999994. This explains the original paper’s alternative. It does not guarantee a large parameter gradient: a zero downstream chain factor still gives zero. Compute the sigmoid complement directly at extreme logits; subtracting a rounded value of one can erase a small but representable derivative.
Dynamics and coverage in one runnable experiment
Save as gan_training.py; run with Python 3.12 and NumPy 1.26.4. There are no external data or random updates. The matrix experiment runs 100 steps from (1,0), using η=0.1 and γ=1 where applicable. Independent tests check the matrix powers, conserved quadratic form and stability boundaries. Trajectory computation and storage are O(T) for T two-dimensional steps.
The second experiment has known finite modes. It evaluates generated mass on valid real modes, population mode coverage, and expected coverage in a sample. These are transparent teaching diagnostics, not a universal image-scoring method. It also computes a best response to a frozen discriminator. With K modes, this part takes O(K) time and space; sample coverage is calculated analytically rather than by drawing repeated samples.
"""Original bilinear min-max game; local stability illustration, not an image GAN."""
import json
import numpy as np
def update_matrix(method, rate=.1, damping=1.):
if (not np.isfinite(rate) or not 0 < rate <= 3
or not np.isfinite(damping) or not 0 <= damping <= 5):
raise ValueError('Rate in (0,3] and damping in [0,5] required.')
if method == 'simultaneous':
return np.array([[1., -rate], [rate, 1.]])
if method == 'alternating':
return np.array([[1., -rate], [rate, 1-rate**2]])
if method == 'damped':
return np.array([[1., -rate], [rate, 1-rate*damping]])
raise ValueError('Choose simultaneous, alternating, or damped.')
def trajectory(method, steps=100, rate=.1, damping=1., initial=(1., 0.)):
if isinstance(steps, bool) or not isinstance(steps, int) or not 0 <= steps <= 1000:
raise ValueError('Integer steps in [0,1000] required.')
state = np.asarray(initial, float)
if state.shape != (2,) or not np.isfinite(state).all() or np.max(abs(state)) > 10:
raise ValueError('Two finite initial coordinates bounded by 10 required.')
matrix = update_matrix(method, rate, damping)
states = [state.copy()]
for _ in range(steps):
state = matrix@state
if not np.isfinite(state).all() or np.max(abs(state)) > 1e100:
raise ValueError('Trajectory exceeds the teaching model numerical range.')
states.append(state.copy())
return np.array(states)
def logit_losses(t):
t = np.asarray(t, float)
if t.size > 256 or not np.isfinite(t).all() or np.any(abs(t) > 100):
raise ValueError('At most 256 finite logits in [-100,100] required.')
sigmoid = np.exp(-np.logaddexp(0., -t))
complement = np.exp(-np.logaddexp(0., t))
return (-np.logaddexp(0., t), np.logaddexp(0., -t), -sigmoid, -complement)
def mode_diagnostics(real, generated, scores, draws=16):
"""Known finite modes only: sample validity, coverage, and frozen-D best response."""
p, q, d = [np.asarray(a, float) for a in (real, generated, scores)]
if (p.ndim != 1 or not 1 <= p.size <= 64 or q.shape != p.shape or d.shape != p.shape
or not all(np.isfinite(a).all() for a in (p, q, d))
or np.any(p < 0) or np.any(q < 0) or abs(p.sum()-1) > 1e-12
or abs(q.sum()-1) > 1e-12 or np.any(d <= 0) or np.any(d >= 1)
or isinstance(draws, bool) or not isinstance(draws, int) or not 1 <= draws <= 1000):
raise ValueError('Aligned probability vectors, D scores in (0,1), integer draws in [1,1000].')
real_modes = p > 0
best = np.zeros_like(q)
best[np.argmax(d)] = 1. # one optimizer; tied maxima allow mixtures too
miss = (1-q)**draws
return dict(valid_mass=float(q[real_modes].sum()),
population_coverage=float(np.mean(q[real_modes] > 0)),
expected_sample_coverage=float(np.mean(1-miss[real_modes])),
miss_probability=miss.tolist(), non_saturating_loss=float(-q@np.log(d)),
best_response=best.tolist(), best_response_loss=float(-best@np.log(d)))
def demo():
runs = {}
for method in ['simultaneous', 'alternating', 'damped']:
states = trajectory(method)
runs[method] = dict(final=states[-1].tolist(),
final_radius=float(np.linalg.norm(states[-1])),
spectral_radius=float(max(abs(np.linalg.eigvals(update_matrix(method))))),
checkpoints=states[::20].tolist())
mm, ns, dmm, dns = logit_losses(np.array([-12., 0., 12.]))
modes = {name: mode_diagnostics([.5, .5, 0], q, [.9, .6, .1])
for name, q in [('matched', [.5, .5, 0]), ('collapsed', [1., 0, 0]),
('rare_mode', [.99, .01, 0])]}
return dict(runs=runs, modes=modes, logits=[-12., 0., 12.], minimax_loss=mm.tolist(),
non_saturating_loss=ns.tolist(), minimax_derivative=dmm.tolist(),
non_saturating_derivative=dns.tolist())
if __name__ == '__main__':
print(json.dumps(demo(), indent=2, allow_nan=False))
Good-looking samples can hide missing modes
For a target with two equally likely modes, a generator that only produces the first mode has valid-sample mass one but covers half the modes. This is mode collapse in a directly inspectable example. It differs from the rotating optimization trajectory: one describes a distribution, the other an update process. They can occur together, but one does not define the other.
Why can repeatedly improving G against a frozen D promote concentration? The non-saturating objective is linear in the generated probability vector q. If the discriminator scores the two modes 0.9 and 0.6, a best response puts all mass at the higher-scoring mode:
The matched distribution’s loss is about 0.308093; the concentrated response improves it to 0.105361 while losing coverage. Tied maxima permit mixtures. This is a best response to a fixed discriminator, not the equilibrium distribution of the joint game. The original paper’s Section 6 warns about training G too much without updating D and mapping many noise values to the same output.
Finite sample inspection adds another difficulty. Even when q=[0.99,0.01] includes both modes, sixteen independent draws miss the second with probability about 0.851458. For known mode probabilities, expected observed coverage follows from indicator expectations:
The absence indicators need not be independent for this expectation formula. Population coverage also says nothing about correct frequencies: both 0.99/0.01 and 0.5/0.5 cover both modes.
For a real training investigation, keep the evaluation sample size fixed; inspect generated frequencies and failure examples, not only a selected grid. Log both players’ objectives and gradient magnitudes, compare a fixed-noise sample across checkpoints, and vary one intervention at a time. Use damping, a different generator loss or update scheduling in response to the diagnosed mechanism. The exact game proves what these interventions do in that game; it cannot choose a universally successful neural-network recipe.
Separate the failures
- From (1,0), take one simultaneous step with η=0.1. What is the squared radius?
Answer: The new pair is (1,0.1), with squared radius 1.01. Both gradients were evaluated correctly, yet the pair moved farther from equilibrium.
- An alternating trajectory preserves Q at a positive value. Has it converged to the origin?
Answer: No. In the stated step-size range Q is positive definite and zero at the origin. A preserved positive Q prevents convergence there.
- Every generated sample lies in the target support, but only one of two target modes appears. Which diagnostic exposes the problem?
Answer: Mode coverage is one half despite valid-sample mass one. Compare frequencies as well: full support coverage alone would still not establish the correct distribution.
- If a mode has generated probability 0.01, does failing to see it in sixteen samples prove its probability is zero?
Answer: No. The miss probability is 0.99^16≈0.851458. Increase the evaluation budget and quantify sampling uncertainty before claiming that a rare mode is absent from the population.
Reading the papers as separate claims
Use Section 3 of the 2014 GAN paper for the non-saturating objective and its Section 6 for the many-noise-values-to-one-output failure. Then read Sections 2.2 and 3.3 of the 2018 convergence paper for rotation and zero-centered regularization. These source locations answer different questions. Its general-network results have additional hypotheses; this article only checks the explicit finite game and finite-mode calculations, rather than claiming to reproduce those full proofs or image experiments.
Make a prediction, then check
Every generated sample is valid, but only one of two real modes appears. What is wrong?
Learning objectives
- Compare simultaneous and alternating updates.
- Predict damping and step-size effects.
- Derive saturating and non-saturating gradients.
- Measure coverage separately from sample validity.
Prerequisites & connections
Explore related knowledge →References
- Generative Adversarial Nets (v1): game, optimal discriminator and limits
Ian J. Goodfellow; Jean Pouget-Abadie; Mehdi Mirza; Bing Xu; David Warde-Farley; Sherjil Ozair; Aaron Courville; Yoshua Bengio · 2014 - Which Training Methods for GANs do actually Converge?
Lars Mescheder; Andreas Geiger; Sebastian Nowozin · 2018
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-13 · Single AI author checked original GAN v1 non-saturating objective/collapse discussion and Mescheder2018 Dirac rotation/zero-centered penalties. Seven paired equations and four explained exercises; exact bilinear dynamics and separate finite-mode diagnostics. No universal neural convergence guarantee.
- Checked matrix powers, simultaneous radius growth, alternating conserved Q, damped eigenvalues and step-size failures; stable logit derivatives; frozen-D mode concentration, valid mass versus coverage and analytic rare-mode miss probability.
- Four computed SVGs bind each actual bilingual program. Group passed16 numerical/geometry checks and24 isolated responsive cases at390/768/1536 with four fallback fonts. Eight final representative screenshots actually viewed. Added VQ numeric labels and equal-unit phase axes with preserved originals; data unchanged. Full article-page acceptance is separate, not independent human review.
Source locations checked:
- Generative Adversarial Nets (v1): game, optimal discriminator and limits · Read Section3 objective/non-saturating training,4.1 optimal D/JS,4.2 conditional convergence and Section6 opening on collapse; inspected PDF page5. Same cached v1 as011o, with expanded reading. No benchmark replication.
- Which Training Methods for GANs do actually Converge? · Read selected Section2.2 Dirac-GAN/rotation and Section3.3 zero-centered penalties; inspected PDF page6 Equations7–8 and small-step qualification. ICML2018, PMLR80:3481–3490. No supplement, full general proof or experiment replication.
Related topics