AI Wiki中文/EN

GAN training: rotation, saturation and missing modes

GAN 训练与模式坍塌

Separate optimization instability from mode coverage using exact games and finite-mode diagnostics.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Both 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.

Exact game trajectories use equal phase-axis units; logit gradients and finite-mode coverage expose separate training failures.
Exact game trajectories use equal phase-axis units; logit gradients and finite-mode coverage expose separate training failures.

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.

min⁡θmax⁡ψL(θ,ψ),L=θψ,v(θ,ψ)=(−ψ,θ).\min_\theta\max_\psi L(\theta,\psi),\qquad L=\theta\psi,\qquad v(\theta,\psi)=(-\psi,\theta).

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:

(θ′ψ′)=M(θψ),M=(1−ηη1),MTM=(1+η2)I.\begin{pmatrix}\theta'\\\psi'\end{pmatrix}=M\begin{pmatrix}\theta\\\psi\end{pmatrix},\quad M=\begin{pmatrix}1&-\eta\\\eta&1\end{pmatrix},\quad M^TM=(1+\eta^2)I.

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:

Malt=(1−ηη1−η2),Q(θ,ψ)=θ2+ψ2−ηθψ,Q(θ′,ψ′)=Q(θ,ψ).M_{\rm alt}=\begin{pmatrix}1&-\eta\\\eta&1-\eta^2\end{pmatrix},\quad Q(\theta,\psi)=\theta^2+\psi^2-\eta\theta\psi,\quad Q(\theta',\psi')=Q(\theta,\psi).

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:

Lγ=θψ−γ2ψ2,J=(0−11−γ),Mγ=I+ηJ,λ(J)=−γ2±γ24−1.L_\gamma=\theta\psi-\frac\gamma2\psi^2,\quad J=\begin{pmatrix}0&-1\\1&-\gamma\end{pmatrix},\quad M_\gamma=I+\eta J,\quad \lambda(J)=-\frac\gamma2\pm\sqrt{\frac{\gamma^2}4-1}.

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:

Jmm(t)=log⁡(1−σ(t)),Jns(t)=−log⁡σ(t),Jmm′(t)=−σ(t),Jns′(t)=−σ(−t).J_{\rm mm}(t)=\log(1-\sigma(t)),\quad J_{\rm ns}(t)=-\log\sigma(t),\quad J'_{\rm mm}(t)=-\sigma(t),\quad J'_{\rm ns}(t)=-\sigma(-t).

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:

JG(q∣D)=−∑iqilog⁡Di,min⁡q∈ΔJG=−log⁡max⁡iDi.J_G(q\mid D)=-\sum_iq_i\log D_i,\quad \min_{q\in\Delta}J_G=-\log\max_iD_i.

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:

Pr⁡(mode i absent in N draws)=(1−qi)N,E[coverage]=1∣SP∣∑i∈SP[1−(1−qi)N],SP={i:pi>0}.\Pr(\text{mode }i\text{ absent in }N\text{ draws})=(1-q_i)^N,\quad \mathbb E[\text{coverage}]=\frac1{|S_P|}\sum_{i\in S_P}[1-(1-q_i)^N],\quad S_P=\{i:p_i>0\}.

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

  1. 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.

  1. 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.

  1. 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.

  1. 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?

Choose one answer

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

  1. 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
  2. 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:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.