W04 · Part 2 — the police, the thief, and the divergence they were minimising
Invalid Date
So change what the model is. Not a formula for a density — a procedure for producing a sample.
Push low-dimensional noise through a network. The output distribution is a genuine object — the pushforward .
Maximum likelihood is unavailable. Note 06: maximising likelihood is minimising — but that requires evaluating .
And KL would be useless anyway. Note 07: two distributions on non-overlapping manifolds have . That is the generic situation here.
So the loss must be computable from samples alone — a batch of real ’s and a batch of fake ’s, with no density anywhere.
That single constraint forces everything that follows.
A counterfeiter prints fake notes and wants them to pass. The police inspect notes and want to catch every fake.
That inability is the certificate of success.
The counterfeiter never sees real money. has no access to the training set. Not one gradient in the generator’s update touches a real image. Everything it learns arrives through .
The police hand over their reasoning, not just their verdict. is differentiable, so receives — the direction in image space that would make the note more convincing.
Rejection sampling throws away a rejected dart and learns nothing. A GAN turns every rejection into a direction.
is the probability that is real — a binary classifier trained with cross-entropy on real vs. generated:
wants this large; wants the second term small. One quantity, two opposed interests:
The generator is judged against the best available critic, not a fixed one.
Otherwise finds the one blind spot of a mediocre and parks there. Hold on to this — when alternating optimisation drifts toward the other order, we get mode collapse.
Note also: . The latent has disappeared; only two distributions remain.
Write both expectations over the same variable:
at one point appears in the integrand only at that point. So — allowing to be any function — maximise the bracket pointwise.
With , , :
At the solution , this is everywhere — the coin flip, exactly as the story promised.
With :
Write for a logit . Then
Two densities nobody can write down — and a classifier recovers their ratio from samples alone. This is the single most reusable idea in the lecture.
Define the mixture — the average of the data and generated distributions:
Substitute into :
each splits as
each expectation of a log-ratio is a KL, by definition
And those two KLs against the mixture are, by definition, twice the Jensen–Shannon divergence.
Goodfellow et al. (2014). with equality only when the two distributions coincide. So the global minimum of is attained exactly at , with value .
A construction motivated by a story about counterfeiters turns out to minimise a specific, symmetric, principled divergence.
The adversary was never a heuristic — it is a variational estimator of a divergence, computing by optimisation what has no closed form.
Three gaps between the theorem and anything you can run:
Every difficulty that follows comes through one of these three gaps.
discriminator steps (usually ) — ascend
One generator step — descend its loss on fresh latents.
chases a moving target: every generator step changes , and therefore changes . Chasing too closely turns out to be as bad as not chasing at all.
The min-max objective gives the loss . Write :
Early in training ’s samples are obvious fakes, so — and the gradient reaching is proportional to .
The generator learns most slowly exactly when it is worst.
Have maximise instead of minimising . Same fixed point — both want — but
Now the gradient is largest when the samples are worst. Essentially every GAN ever trained uses this.
Arjovsky & Bottou (2017): at an optimal discriminator, the non-saturating generator gradient is the gradient of
The loss people actually train is not a divergence, is mode-seeking, and contains a repulsive term. Mode collapse is visible in the objective.
Note 07 §8: if and have essentially disjoint supports — generic, since both are manifolds in a high-dimensional space —
Not small. Zero. “Maximally different”, with no direction attached.
The theory wants optimal. An optimal gives no gradient.
The non-saturating loss patches the symptom. WGAN removes the cause: replace JS with , which reports the actual distance between separated supports and keeps a gradient pointing home. That is why note 07 came before this lecture.
maps every latent to the same output, or a handful. Ten digit classes in, convincing sevens out — and nothing else. Three explanations, all correct:
The min and max swap. Alternating optimisation drifts toward . There, moves first against a fixed , and its optimal response is to put all mass on — a delta function is the exact solution.
The divergence is mode-seeking — reverse KL covers one mode well rather than all modes poorly.
Nothing penalises missing mass. judges samples one at a time. Diversity is a property of a set, invisible to a pointwise classifier.
An MH chain trapped in one mode looks perfectly healthy — good acceptance, stable trace — while sampling the wrong distribution.
A mode-collapsed GAN looks perfectly healthy — sharp samples, low losses — while modelling the wrong distribution.
Locally correct everywhere; globally wrong. And in both cases the diagnostic that would reveal it is the one the algorithm never computes.
Ordinary training minimises one function, and “the loss went down” means progress. Here the target is a saddle point, and descending a loss is not a correct algorithm for finding one.
The smallest instance: , equilibrium at the origin. Simultaneous gradient steps of size :
the cross terms cancel exactly
Distance from the equilibrium grows at every step, for any . As the iterates orbit forever and never converge.
This is a convex–concave game — the friendliest case that exists — and gradient descent-ascent still fails on it.
| Problem | Fix |
|---|---|
| Vanishing gradient | non-saturating loss |
| Vanishing gradient | WGAN + gradient penalty — swap JS for , an IPM |
| Vanishing gradient | instance noise — make the supports overlap |
| Mode collapse | minibatch discrimination — let see batch statistics |
| Mode collapse | unrolled GANs — let see ’s future response |
| Instability | spectral normalisation; two time-scale updates |
| Generality | -GAN — the same template for any -divergence |
The fix for disjoint supports: add Gaussian noise to both real and fake samples, so both acquire full support and the ratio becomes finite again.
It works. It was regarded as a trick.
A diffusion model does this at every noise level, simultaneously and deliberately. The forward process is a whole continuum of noised versions of , and the model learns to reverse each level.
What GANs had to smuggle in as a stabiliser is the diffusion model’s organising principle.
| Metropolis–Hastings | GAN | |
|---|---|---|
| Proposal | chosen by hand | learned |
| Density ratio | computed from | estimated by a classifier |
| Requires | evaluable | samples only |
| A rejection | chain stays put | becomes a direction |
| Output | exact, correlated draws | approximate, independent draws |
| Per sample | thousands of steps, every time | one forward pass |
A trained gives a density ratio for two distributions nobody can write down — so you can run an MH accept/reject step on a GAN’s own samples. That is exactly what MH-GAN (2019) does.
The construction. No likelihood means the loss must come from samples; a classifier separating real from fake supplies it, and its logit is the log density ratio.
The theorem. At an optimal the game minimises , uniquely minimised at .
The trouble. JS saturates between disjoint manifolds, killing the gradient exactly when is good; and a saddle point is not a minimum, so descent has no reason to converge.
A GAN is a learned proposal with a learned judge. It fixed what was wrong with Metropolis–Hastings — and inherited a new problem: the judge is an adversary.
The rest of this course removes the judge. A diffusion model’s forward process adds a small amount of noise at each of many steps, so each reverse step is nearly Gaussian and can be matched by direct regression against a target computed from real data.
No adversary. No saddle point. No accept/reject. And a loss whose descent means progress.
| Today | Where it returns |
|---|---|
| Implicit model | flows, decoders, the diffusion sampler |
| Logit | classifier guidance, Module 6 |
| JS pinned at | note 07 §8, and the motivation for WGAN |
| Instance noise | the forward diffusion process, Module 3 |
| Reverse KL is mode-seeking | the ELBO’s KL term, Module 3 |
| Adversarial training as a game | why a direct regression objective is worth a lot |
You cannot write the density down, so you train a critic to smell the difference — and it turns out you were minimising Jensen–Shannon all along.
Reference: 09 · Generative Adversarial Networks. Background: 07 · Comparing Distributions. Next: Module 3, where the critic disappears.