Generative Adversarial Networks
A two-player game with a forger and a critic.
Goodfellow et al. proved in 2014 that, against an optimal discriminator, the GAN game minimizes a Jensen–Shannon divergence with a unique solution . The field then spent years learning why that clean theorem says little about training: the divergence saturates when supports barely overlap, and gradient play on a game can circle forever. This lesson proves the theorem, generalizes it to -divergences, and follows the Wasserstein repair and the game dynamics.
What you’ll learn
- Prove that the value of the GAN game at the optimal discriminator is , and derive the -GAN variational bound.
- Prove that the non-saturating generator loss follows , and explain its mode-seeking bias.
- Explain why JS-type objectives fail on non-overlapping supports, and state and sketch Kantorovich–Rubinstein duality and the continuity of .
- Analyze gradient descent–ascent on a bilinear game, and connect it to GAN instability, mode collapse and their remedies.
The game and its optimum
(i) is pointwise maximization of , maximized at , as derived in the Hidden Layer lesson. Substitute :
Write each denominator as and pull out twice:
which is (ii). For (iii): each KL is , with equality iff (Gibbs' inequality). And , so each KL is , with equality iff the other density vanishes wherever this one is positive:
The paper's convergence result (Proposition 2) says that if is maximized at every step and takes small gradient steps on in the space of densities, then , because is convex in . Real training breaks all three assumptions: is parameterized by , in which is not convex, gets a few gradient steps rather than being maximized, and both are networks of finite capacity.
Finite capacity cuts both ways. Against a discriminator class with parameters, the game measures a weaker "neural net distance", and Arora et al. (2017) showed that a distribution supported on about points (up to logarithmic factors) can come within of the data in that distance. Winning the game does not imply covering the data.
f-divergences and the non-saturating loss
For a convex with , the -divergence is ; KL, reverse KL, JS, total variation and Pearson are all members. Its convex conjugate is , and for a lower-semicontinuous convex conjugation is an involution, (Fenchel–Moreau).
Fenchel–Moreau gives, at each , with and any value :
Multiply by and integrate:
The supremum over is attained where , equivalently (Fenchel–Young equality), so is optimal.
| Divergence | Optimal | ||
|---|---|---|---|
| KL | |||
| Reverse KL | |||
| Pearson | |||
| GAN () |
By the envelope theorem, the -dependence of the optimal does not contribute at the optimum, so differentiating only through the samples gives:
Since , and the expected score is zero, the KL's gradient reduces to an expectation of this fixed function:
Subtract the second line from the first and negate. The reverse KL is mode-seeking: it is infinite where puts mass off the data but cheap where misses data, and the term even rewards pushing the distributions apart. The loss that fixes saturation builds in a bias toward dropping modes.
When supports do not overlap: Wasserstein GANs
A generator maps a low-dimensional into image space, so lives on a low-dimensional set, and natural images are believed to concentrate near one too. Two such sets generically do not overlap. Arjovsky & Bottou (2017) proved that when the supports lie in disjoint compact sets (or on manifolds that do not perfectly align), a smooth discriminator separates them perfectly, JS sits at its maximum , and the gradient the generator receives through a near-optimal discriminator vanishes. The simplest example shows what a better distance must do:
| Distance between and | Value for | Useful gradient in ? |
|---|---|---|
| Jensen–Shannon | (and at ) | no: constant, then a jump |
| no | ||
| Total variation | no | |
| Wasserstein-1 | yes: it points toward |
Weak duality. For any coupling and any 1-Lipschitz , write the difference of expectations under ; take the infimum over and the supremum over :
Finite supports. The primal is a linear program in with row sums , column sums and costs . LP duality gives equality with the dual:
Replace by , defined on the whole space: still feasible, no worse, and 1-Lipschitz as a minimum of 1-Lipschitz functions. For 1-Lipschitz , the best given is , attained at . With :
General measures follow by approximating with finitely supported ones, using the stability of both sides (Villani, 2009). Continuity in is a one-line coupling argument: draw the same for both generators and use the triangle inequality.
So if is continuous in (with enough integrability), is continuous in , and if is locally Lipschitz with integrable constants it is differentiable almost everywhere (Arjovsky, Chintala & Bottou, 2017). JS and KL have neither property.
The WGAN critic , which has no sigmoid, maximizes subject to a Lipschitz constraint. The original paper clipped the weights, which is crude and limits capacity. WGAN-GP (Gulrajani et al., 2017) instead penalizes at random interpolates between real and fake points, because the optimal critic has unit gradient norm along the transport lines. Spectral normalization (Miyato et al., 2018) bounds each layer's operator norm. Because the critic class is restricted, all of these minimize a neural-network proxy for , not itself.
In the parallel-lines example, the generator sits at . Which objective gives it a gradient that points toward the data at ?
- Jensen–Shannon
- Wasserstein-1
- Total variation
Show the answer
C. Wasserstein-1
, so at , and a gradient step moves toward . The other three are constant for all , so their gradients are zero (or undefined).
Training dynamics, mode collapse and the frontier
Training is gradient play: and , simultaneously or in alternation. Even in convex–concave games this need not converge. The bilinear game , whose unique equilibrium is , shows why.
The continuous-time flow , has a Jacobian with eigenvalues : the iterates circle the equilibrium forever, conserved.
Simultaneous discrete steps apply , with eigenvalues of modulus : the iterates spiral outward for every step size.
Alternating steps (update with the new ) give a matrix of determinant whose eigenvalues lie on the unit circle for : bounded cycles, still no convergence. Extragradient and optimistic gradient methods add a correction that does converge on bilinear games (Daskalakis et al., 2018).
Simultaneous gradient descent–ascent on with step runs for steps. By what factor has the distance from the equilibrium grown?
Show the answer
1.64
. Smaller steps slow the drift, about , but never reverse it.
The same structure appears in a real GAN. In the Dirac-GAN of Mescheder, Geiger & Nowozin (2018), with data , generator and discriminator , the Jacobian at the equilibrium has purely imaginary eigenvalues, and unregularized training does not converge. A zero-centered gradient penalty on real data, , adds damping and makes training locally convergent. Using a larger learning rate for than for , the two time-scale update rule, comes with a convergence proof to local Nash equilibria under stochastic-approximation assumptions (Heusel et al., 2017).
Mode collapse has a simple mechanism. For a fixed discriminator, the generator's best response is to send every to , a point mass. The discriminator then learns to reject that point, and the generator hops to another: the cycling seen in practice. Remedies let see sample diversity (minibatch discrimination; Salimans et al., 2016) or let anticipate 's response (unrolled GANs; Metz et al., 2017).
To measure low diversity, Arora, Risteski & Zhang (2018) proposed a birthday-paradox test. Among draws from a uniform distribution on items, the probability of a repeat is , which reaches at . If batches of samples often contain near-duplicates, the support is likely not much larger than . Applied to GANs of the time, the test found near-duplicates in batches of moderate size, evidence of supports far smaller than the variety of the data.
Key takeaways
- Against the optimal discriminator , the GAN value is , minimized exactly at ; the convergence proof holds only in function space.
- , with equality at : every -divergence yields a GAN, and the original GAN is the case .
- The non-saturating loss follows , a mode-seeking direction; for a fixed discriminator, the generator's best response is a point mass.
- On non-overlapping low-dimensional supports, JS, KL and TV are flat or infinite while stays continuous; WGAN critics approximate the Lipschitz class with clipping, gradient penalties or spectral normalization.
- Gradient play on games can cycle or diverge: on , simultaneous steps grow by per step. Gradient penalties, two time-scale updates and extragradient-type methods restore local convergence.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
If and have disjoint supports, what is ?
Show the answer
B.
JS reaches its maximum , so . Indeed a perfect discriminator outputs on real data and on fakes, and both log terms are . The value cannot change under small moves of the generator, which is why gradients vanish.
In the -GAN bound with , so that , which critic attains equality?
Show the answer
C.
and . Check: with , the bound becomes .
Kantorovich–Rubinstein duality writes as the supremum of over which functions?
- All functions with values in
- All 1-Lipschitz functions
- All bounded continuous functions
- All convex functions
Show the answer
B. All 1-Lipschitz functions
The Lipschitz constraint matches the transport cost : weak duality is integrated over any coupling. WGAN critics are regularized (clipping, gradient penalty, spectral normalization) to approximate this class.
What does simultaneous gradient descent–ascent with step do on , starting away from ?
- It converges linearly to if is small enough
- It orbits on a fixed circle around
- It jumps to in one step if
- It spirals outward, its distance from multiplying by each step
Show the answer
D. It spirals outward, its distance from multiplying by each step
The update matrix is times a rotation, for every . Small steps only slow the divergence; converging requires changing the method (extragradient, optimism) or adding damping (gradient penalties).
Further reading
- I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville & Y. Bengio, "Generative adversarial nets," NeurIPS (2014).
- S. Nowozin, B. Cseke & R. Tomioka, "f-GAN: Training generative neural samplers using variational divergence minimization," NeurIPS (2016).
- M. Arjovsky, S. Chintala & L. Bottou, "Wasserstein generative adversarial networks," ICML (2017).
- L. Mescheder, A. Geiger & S. Nowozin, "Which training methods for GANs do actually converge?" ICML (2018).
- C. Villani, Optimal Transport: Old and New (Springer, 2009).