generative_continuous / 21 · evaluation & GANs lesson 21 / 23

Did it work? Evaluation & the GAN contrast

Every lesson so far has said “better samples” without measuring. Here is how IS and FID actually quantify it — and what they miss. Then the model diffusion dethroned: GANs, mode collapse, and why the trade was worth it.

The measurement problem

We never have pdata in closed form — only samples (lesson 1). So “is the generated distribution close to the real one” can’t be a likelihood for most models (and for GANs there is none). The field’s answer: push both real and fake images through a frozen Inception-v3 classifier and compare them in feature space, where “looks like a real image” becomes a measurable statistic. Two metrics do this differently.

Inception Score (IS): sharp and varied, from one network

IS uses only generated images and the classifier’s label distribution p(y|x). It rewards two things at once:

Both at once = each conditional far from the marginal = high KL between them, averaged and exponentiated:

IS = exp( 𝔼x∼pg [ KL( p(y|x) ‖ p(y) ) ] )    (higher is better)
What IS cannot see

Fréchet Inception Distance (FID): compare to the real data

FID fixes IS’s biggest hole — it compares fakes against reals. The whole idea is simple even though the formula looks heavy: run both sets of images through Inception, and each image becomes a point in a 2048-dimensional “what-it-looks-like” space. The real images form one cloud of points; the fakes form another. Summarize each cloud by where its center sits and how it’s spread out — i.e. fit one Gaussian blob to each — then ask: how far apart are these two blobs? The closed-form answer is the Fréchet (Wasserstein-2) distance between two Gaussians:

FID = ‖ μr − μg ‖² + Tr( Σr + Σg − 2 (Σr Σg)½ )    (lower is better)

The formula is just “distance between two blobs,” in two parts. First term: how far apart are the two centers (do fakes have the right average content)? Second term: how differently are the two clouds spread out (do fakes have the right diversity)? Mode collapse shrinks the fake cloud — its spread Σg drops — which inflates the trace term, so unlike IS, FID catches collapse. This is why FID is the field standard and why the diffusion lessons’ “better samples” ultimately means “lower FID at matched compute.”

Intuition · linear unpacking

Claim: the scary FID formula is just the distance between two clouds of points in feature space — one cloud of real images, one of fakes.

  1. Images become points. Inception turns each image into 2048 numbers. “Looks like a real photo” is now a location in that space, and a whole dataset is a cloud of locations.
  2. Summarize each cloud by two facts. Where is it centered (the mean μ), and how fat / which way is it stretched (the covariance Σ)? That’s all a Gaussian blob is — a center plus a spread.
  3. Compare the two blobs, piece by piece. The ‖μr − μg‖² term measures the gap between the two centers; the trace term measures the gap between the two spreads. Both zero only when the fake blob sits exactly where the real one does and is shaped the same.
  4. Why collapse shows up. If the generator only makes a few looks, its cloud is tiny and tight. Even if its center is right, its spread no longer matches the real cloud’s — the trace term grows and FID rises.

Central point. Lower FID = the two point-clouds sit in the same place and are shaped the same way; the matrix algebra is only the bookkeeping for “same center, same spread.”

What FID still cannot see

For text-to-image specifically you also want CLIP-score — cosine similarity between the prompt’s CLIP-text embedding and the image’s CLIP-image embedding (lesson 20) — because FID measures realism, not prompt adherence. Production reports usually plot the FID–CLIP trade-off as you sweep guidance scale (lesson 18).

The model diffusion beat: GANs

A GAN (Goodfellow 2014) is two networks in a game: a generator G maps noise z∼N(0,I) to an image; a discriminator D tries to tell real from fake. The single line below is just “these two fight” written as math: D wants to push the expression up (score reals near 1, fakes near 0), G wants to push it down (fool D into scoring its fakes near 1). The maxD says “D plays first and best”; the minG says “G then tries to undo that.”

minG maxD   𝔼x∼pdata[log D(x)] + 𝔼z[log(1 − D(G(z)))]

No likelihood, no slow sampling — one forward pass through G makes an image. That speed was the appeal. The cost is the contrast with everything in Part A:

Intuition · linear unpacking

Claim: the GAN game is unstable because G chases a moving target, while diffusion just regresses against a fixed answer key.

  1. Diffusion has a fixed grader. Its loss ‖ε − εθ‖² compares the model’s guess to the actual noise that was added — a known, unchanging right answer. “Better” always means the same thing, so the target never wobbles.
  2. A GAN has no fixed answer key. G’s only feedback is D’s opinion — and D is itself being trained. The thing G is graded against keeps changing every step.
  3. Two players chasing each other. G learns to beat today’s D; D then adapts to beat that G. Neither sits still, so the loss can oscillate forever instead of settling — like two people leaning to counter each other and toppling.
  4. And nothing demands coverage. The objective only asks G to fool D. If one image reliably fools it, there is no term saying “also make the rest of the data” — the seed of mode collapse.

Central point. Stable regression against a known target (diffusion) is a far calmer thing to optimize than a tug-of-war against an opponent who keeps moving the goalposts (GAN).

GANDiffusion
Trainingadversarial minimax — unstable, oscillates, needs careful balancingplain regression (lesson 3) — stable, just MSE
Sampling1 forward pass — fastmany steps (lesson 17) — slower, but distillable
Diversityprone to mode collapsecovers modes (the loss touches all data)
LikelihoodnoneELBO / exact via PF-ODE (lesson 16)

Mode collapse: the GAN failure diffusion avoids by construction

Mode collapse is the generator dumping all its mass on a few outputs that reliably fool D, abandoning whole regions of pdata. The mechanism: G only ever receives gradient through D; if it finds one image D can’t reject, the minimax has no term forcing coverage of other modes — nothing in the objective says “also generate the rest.” Diffusion can’t do this: its loss is 𝔼x₀∼data‖ε−εθ‖² over the real data, so every mode contributes gradient every step.

The standard list of fixes, with the lever each pulls:

FixLever
WGAN (Wasserstein distance)replace JS divergence (which gives vanishing gradient when supports don’t overlap) with Earth-Mover distance — smoother signal
WGAN-GP (gradient penalty)enforce the 1-Lipschitz constraint WGAN needs, without weight clipping
Minibatch discrimination / stdlet D see batch-level variety, so a collapsed batch is detectable
Unrolled GANlet G optimize against D’s future steps, so it can’t exploit a momentary D
Experience replay, multiple Gs, one-sided label smoothingvarious ways to stop D from being exploited or over-confident
Why the trade was worth it — and why GANs aren’t dead
Diffusion traded GANs’ one-pass speed for stable training and mode coverage; “Diffusion Models Beat GANs” (Dhariwal & Nichol 2021, the same classifier-guidance paper, lesson 18) was the FID-on-ImageNet moment. But the wheel turns: the one-pass speed advantage is exactly what few-step distillation chases (lesson 17), and adversarial losses came back — inside the SD VAE decoder (lesson 19) and in adversarial diffusion distillation (SDXL-Turbo). GANs lost as the primary generator and survived as a component.

Interactive · FID and mode collapse on a toy

The target is a ring of 8 Gaussian modes (the classic mode-collapse benchmark). Dial a generator from “full coverage” to “collapsed onto 2 modes” and watch the metrics: the toy-FID (computed in raw 2D here, same formula) rises as coverage drops because the covariance term Tr(Σrg−2(ΣrΣg)½) blows up — FID sees the collapse. A naive “mean distance only” score (mimicking IS’s blind spot) barely moves.

8-mode ring · coverage vs. toy-FID
Slide coverage from 8 modes down to 1. Orange = generator samples, green = real modes. FID (with the covariance term) climbs sharply as modes vanish; the mean-only score stays low — the IS blind spot, visualized.
toy-FID (full)
mean-only score
covariance term
Punchline
IS = sharp-and-varied from the classifier alone (blind to real data and to within-class collapse). FID = Fréchet distance between Gaussian fits of real vs. fake Inception features (catches collapse via the covariance term; still blind to spatial layout and overfitting). GANs sample in one pass but train adversarially and mode-collapse; diffusion trades passes for stable, mode-covering regression — then steals the speed back with distillation.