Simple Algorithm
Deep Learning · Emergence · 28 min

Evaluating Generative Models

Likelihood, FID, precision and recall, memorization, and why metrics disagree.

A model can have excellent likelihood and produce garbage 99% of the time. Another can produce flawless images and have learned nothing beyond its training set. The standard image score turns out to measure, largely, the distribution of ImageNet classes. Evaluating generative models is a field of its own, and its first lesson is that every number measures something narrower than "quality".

What you’ll learn

  • Prove that likelihood and sample quality can disagree, using mixtures and lookup tables, and convert likelihoods to bits per dimension.
  • Derive the Inception Score as an exponentiated mutual information, compute FID for Gaussians, and explain FID's sample-size bias and its dependence on the feature extractor.
  • Define precision, recall, density and coverage for distributions, and relate them to truncation and mode collapse.
  • Explain how memorization is detected, why an exactly optimal denoiser on finite data memorizes, and what is known about when diffusion models generalize.

Likelihood, and why it is not enough

For models with a likelihood, the natural score is the average log-likelihood of held-out data, reported for images in bits per dimension: −log⁡2p(x)/D-\log_2p(\mathbf x)/D for DD pixel values, which is the compression rate the model would achieve. Continuous densities on 8-bit images are evaluated after adding uniform noise to the integer pixel values (dequantization), so that a density cannot cheat by piling infinite mass on discrete points. Autoregressive models and flows give the number exactly; VAEs and diffusion models give a bound or an estimate; GANs give nothing.

Theis, van den Oord & Bethge (2016) showed that average log-likelihood, sample quality and Parzen-window estimates (likelihoods fitted to samples, then common for GANs) are largely independent in high dimensions. Two constructions make the point.

Predict before you look

A model of 32×3232\times32 color images is mixed with 99% noise as above. At most how many nats per image does its log-likelihood worsen?

Show the answer

4.61 nats

log⁡100≈4.61\log100\approx4.61 nats, whatever the model. Spread over D=32⋅32⋅3=3,072D=32\cdot32\cdot3=3{,}072 dimensions that is 4.61/(3072ln⁡2)≈0.0024.61/(3072\ln2)\approx0.002 bits per dimension, far below the differences between published models, yet 99 samples in 100 are noise.

The converse also holds. A lookup table that outputs random training images, or a mixture of narrow Gaussians centered on them, produces perfect-looking samples but gives held-out images essentially zero density: great samples, terrible likelihood. And likelihood can mislead in a third way: Nalisnick et al. (2019) found that flows, VAEs and PixelCNNs trained on CIFAR-10 assign higher likelihood to the street-number images of SVHN, data they never saw, so likelihood alone cannot flag unfamiliar inputs. Much of an image's likelihood is spent on low-level statistics, such as smoothness and local correlations, that say little about content.

Inception Score and FID

Sample-based scores replace densities with statistics of a pretrained network's outputs on generated images. The Inception Score (Salimans et al., 2016) feeds samples to an ImageNet classifier (Inception-v3) and rewards two things: each image should be classified confidently, p(y∣x)p(y\mid\mathbf x) peaked, and the classes should be spread out, the marginal p(y)=Ex[p(y∣x)]p(y)=\E_{\mathbf x}[p(y\mid\mathbf x)] flat:

DerivationThe Inception Score is an exponentiated mutual information
  1. IS=exp⁡(Ex∼pgDKL(p(y∣x) ∥ p(y))),ExDKL(p(y∣x) ∥ p(y))=H(y)−H(y∣x)=I(y;x)\mathrm{IS}=\exp\Big(\E_{\mathbf x\sim p_g}\KL\big(p(y\mid\mathbf x)\,\|\,p(y)\big)\Big),\qquad\E_{\mathbf x}\KL\big(p(y\mid\mathbf x)\,\|\,p(y)\big)=H(y)-H(y\mid\mathbf x)=I(y;\mathbf x)

    Average the KL divergence over generated images and expand it:

  2. 1≤IS=eI(y;x)≤eH(y)≤K=10001\le\mathrm{IS}=e^{I(y;\mathbf x)}\le e^{H(y)}\le K=1000

    Mutual information is at most the entropy of yy, which is at most log⁡K\log K for KK classes:

  3. The maximum is reached by a generator that produces one perfectly classifiable image per class, equally often. Hence the score's blind spots, catalogued by Barratt & Sharma (2018): it never looks at real data, ignores diversity within a class, depends on the classifier's exact weights and implementation, means little for data unlike ImageNet's classes, and can be gamed by images optimized to be classified confidently.

The Fréchet inception distance (Heusel et al., 2017) does compare with real data. Take the 2,048-dimensional pool features of Inception-v3 for real and generated images, fit a Gaussian to each set, and report the squared 2-Wasserstein (Fréchet) distance between the two Gaussians:

FID=∥μr−μg∥22+Tr⁡(Σr+Σg−2(ΣrΣg)1/2)\mathrm{FID}=\norm{\boldsymbol\mu_r-\boldsymbol\mu_g}_2^2+\Tr\Big(\Sigma_r+\Sigma_g-2\big(\Sigma_r\Sigma_g\big)^{1/2}\Big)
Lower is better, and 00 means the two Gaussian fits coincide. The first term compares average features, the trace term their spreads, so FID reacts to fidelity and diversity at once, without separating them.
Predict before you look

In one dimension, real features follow N(0,1)\mathcal N(0,1) and generated features N(1,4)\mathcal N(1,4) (variance 4). What is the FID?

Show the answer

2

(0−1)2+(1+4−21⋅4)=1+1=2(0-1)^2+\big(1+4-2\sqrt{1\cdot4}\big)=1+1=2. In one dimension the formula reduces to (μr−μg)2+(σr−σg)2(\mu_r-\mu_g)^2+(\sigma_r-\sigma_g)^2: here a unit shift in mean and a doubled standard deviation contribute equally.

FID became the standard image metric, and its problems are well documented:

  • Bias with sample size. Estimated from NN samples, FID is biased upward, roughly by a term proportional to 1/N1/N whose size depends on the generator, so two models compared at the same NN can swap order at another. Chong & Forsyth (2020) fit FID against 1/N1/N and extrapolate to N→∞N\to\infty (FID∞\mathrm{FID}_\infty). The Kernel Inception Distance (Bińkowski et al., 2018), a squared maximum mean discrepancy with the polynomial kernel k(a,b)=(a⊤b/d+1)3k(\mathbf a,\mathbf b)=(\mathbf a^\top\mathbf b/d+1)^3 on the same features, has an unbiased estimator and assumes no Gaussian shape.
  • Preprocessing. Resizing with an aliasing filter, or JPEG compression, measurably shifts FID (Parmar, Zhang & Zhu, 2022), so numbers from different code are not comparable.
  • The feature space. Kynkäänniemi et al. (2023) showed that Inception features are so tied to ImageNet classes that FID behaves largely like a distance between class-probability distributions: matching the histogram of top predicted classes can lower FID substantially without improving the images.
  • Agreement with people. In the largest human study of its kind, Stein et al. (2023) found that no existing metric correlated strongly with human judgments of realism and that Inception features unfairly penalized diffusion models; replacing them with DINOv2 ViT-L/14 features (a "Fréchet DINOv2 distance") removed the discrepancy in their study.

Precision and recall for distributions

FID folds two failures into one number: samples that look wrong, and data that the model never produces. A truncated GAN and a blurry VAE can have the same FID for opposite reasons. The fix borrows precision and recall from classification.

In practice the distributions are known only through samples in a feature space, so the standard estimators approximate each distribution's support by a union of balls. With real features x1,…,xN\mathbf x_1,\dots,\mathbf x_N, generated features y1,…,yM\mathbf y_1,\dots,\mathbf y_M, and B(xi)B(\mathbf x_i) the ball around xi\mathbf x_i whose radius is the distance to its kk-th nearest real neighbor:

  • Precision and recall (Kynkäänniemi et al., 2019): precision is the fraction of generated samples that fall inside some real ball; recall is the fraction of real samples that fall inside the balls built the same way around the generated samples.
  • Density and coverage (Naeem et al., 2020): density =1kM∑j∑i1[yj∈B(xi)]=\frac1{kM}\sum_j\sum_i\mathbb 1[\mathbf y_j\in B(\mathbf x_i)] counts how many real balls contain each generated sample, so a generated sample that lies only inside one real outlier's oversized ball adds 1/k1/k rather than a full count; coverage =1N∑i1[∃j:yj∈B(xi)]=\frac1N\sum_i\mathbb 1[\exists j:\mathbf y_j\in B(\mathbf x_i)] is the fraction of real samples with at least one generated sample nearby. Both use only real-sample balls, which makes them more robust to outliers, and density has expected value 11 when the two distributions are identical.

Kynkäänniemi et al. used their metric to analyze the truncation trick: as truncation strengthens, precision rises and recall falls, the trade-off that FID alone hides.

Check your understanding

The data are an equal mixture of 8 well-separated modes. A model produces flawless samples from exactly 4 of them, equally often, and nothing else. What are its precision and recall in the sense of Sajjadi et al.?

  1. Precision 0.50.5, recall 11
  2. Precision 0.50.5, recall 0.50.5
  3. Precision 11, recall 11, since every sample is flawless
  4. Precision 11, recall 0.50.5
Show the answer

D. Precision 11, recall 0.50.5

Take μ\mu uniform over the 4 modes the model produces. Then Q=1⋅μQ=1\cdot\mu, so α=1\alpha=1, and P=0.5 μ+0.5 νPP=0.5\,\mu+0.5\,\nu_P with νP\nu_P the other 4 modes, so β=0.5\beta=0.5. All of the model is right, but it covers only half of the data: the signature of mode collapse.

Conditional models need a third axis: does the image match its prompt? CLIPScore (Hessel et al., 2021), introduced to rate image captions without reference captions, is w⋅max⁡(cos⁡(eimage,etext),0)w\cdot\max(\cos(\mathbf e_{\text{image}},\mathbf e_{\text{text}}),0) with CLIP embeddings and w=2.5w=2.5, and it is widely used to score prompt alignment in text-to-image generation; it inherits the blind spots of CLIP's embeddings. Human judgments, usually side-by-side preferences, remain the reference standard for quality and alignment, at the price of cost, noise and poor reproducibility.

Memorization and generalization

None of the metrics above can tell a model that generalizes from one that copies: a lookup table has excellent precision, recall and FID. Memorization has to be tested directly, by comparing generations with the training set.

Carlini et al. (2023) attacked image diffusion models with a generate-and-filter procedure: sample many images for prompts taken from the training captions, flag outputs that are suspiciously consistent across samples, and check them against the training data. They extracted over a thousand training examples from state-of-the-art models, from photographs of individual people to trademarked logos, and found diffusion models considerably less private than the GANs they compared. Somepalli et al. (2023) used copy-detection features to search generations for replicated training content, found that replication depends strongly on training-set size, and documented Stable Diffusion reproducing training images.

Why should diffusion models memorize at all? Because the training objective, solved exactly, demands it.

So generalization in diffusion models comes from not reaching this optimum: from the network's architecture, its finite capacity and the length of training. Two lines of evidence make this concrete.

  • Kadkhodaie, Guth, Simoncelli & Mallat (2024) trained two denoisers on non-overlapping subsets of a face dataset. With small training sets each memorized its own images; with large enough sets the two learned nearly the same denoiser, and therefore nearly the same density, so their samples cannot be copies of either half. They traced the generalization to an inductive bias: the networks denoise by shrinkage in bases adapted to the image's geometry, with oscillating harmonic structure along contours and in smooth regions.
  • Bonnaire, Urfin, Biroli & Mézard (2025) found two time scales in training: a time τgen\tau_{\text{gen}} at which samples become good, roughly independent of the training-set size nn, and a later time τmem\tau_{\text{mem}} at which memorization sets in, growing linearly with nn. The window in which a model generalizes therefore widens with more data, and early stopping exploits it; they support this with U-Net experiments and an analysis of a random-features model in high dimensions.

Key takeaways

  • Likelihood (in bits per dimension), sample quality and diversity are largely independent: mixing in 99% noise costs at most log⁡100≈4.61\log100\approx4.61 nats per image, a lookup table has great samples and terrible likelihood, and likelihoods can rank unfamiliar data above familiar data.
  • IS=eI(y;x)≤K\mathrm{IS}=e^{I(y;\mathbf x)}\le K ignores real data and within-class diversity. FID is the Fréchet distance between Gaussian fits to Inception features, biased upward at finite NN, sensitive to preprocessing, and tied to ImageNet classes; KID and better feature spaces address parts of this.
  • Precision and recall for distributions separate fidelity from coverage; kk-nearest-neighbor estimators (precision–recall, density–coverage) make them practical, and truncation trades one for the other.
  • Memorization must be tested against the training data directly. The exact optimal denoiser on finite data memorizes, so diffusion models generalize only through inductive bias and training dynamics, with a generalization window that widens with the training-set size.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A generator's samples are each classified with certainty, and all of them fall into a single ImageNet class. What is its Inception Score?

  1. 10001000, the maximum, since every classification is confident
  2. 11, because the mutual information between image and class is zero when the class never varies
  3. 500500
  4. It is undefined
Show the answer

B. 11, because the mutual information between image and class is zero when the class never varies

log⁡IS=I(y;x)=H(y)−H(y∣x)\log\mathrm{IS}=I(y;\mathbf x)=H(y)-H(y\mid\mathbf x). Confident predictions make H(y∣x)=0H(y\mid\mathbf x)=0, but a single class makes H(y)=0H(y)=0 too, so IS=e0=1\mathrm{IS}=e^0=1, the minimum. The maximum, 10001000, needs confident predictions spread evenly over all classes.

Question 2

Paper A reports FID computed from 10,000 samples, paper B from 50,000, for different models. What is the main problem with comparing the two numbers?

  1. None: FID is an unbiased estimate, so sample size only affects its noise
  2. FID is biased upward at finite NN, by an amount that depends on both NN and the model, so numbers at different NN (and even different models at the same NN) are not directly comparable
  3. FID can only be computed from exactly 50,000 samples
  4. FID decreases as NN shrinks, so paper A's model looks better than it is
Show the answer

B. FID is biased upward at finite NN, by an amount that depends on both NN and the model, so numbers at different NN (and even different models at the same NN) are not directly comparable

The finite-sample bias is roughly proportional to 1/N1/N with a model-dependent constant. Chong & Forsyth (2020) extrapolate to FID∞\mathrm{FID}_\infty; KID offers an unbiased alternative. Preprocessing differences add further incompatibilities.

Question 3

A diffusion model's denoiser is trained to the exact minimum of its loss on a finite training set. What will the sampler produce?

  1. New images from the true data distribution, since the loss is minimized
  2. Blurry averages of all training images
  3. Only images from the training set: the exact optimal denoiser is a softmax-weighted average of training images that collapses to the nearest one as the noise vanishes
  4. Pure noise
Show the answer

C. Only images from the training set: the exact optimal denoiser is a softmax-weighted average of training images that collapses to the nearest one as the noise vanishes

The optimum is the posterior mean under the empirical distribution. Its reverse process ends on training points, so any generalization must come from the network not fitting this optimum: inductive biases, limited capacity and finite training, as Kadkhodaie et al. (2024) and Bonnaire et al. (2025) study.

Further reading

  • L. Theis, A. van den Oord & M. Bethge, "A note on the evaluation of generative models," ICLR (2016).
  • M. Heusel, H. Ramsauer, T. Unterthiner, B. Nessler & S. Hochreiter, "GANs trained by a two time-scale update rule converge to a local Nash equilibrium," NeurIPS (2017).
  • T. Kynkäänniemi, T. Karras, S. Laine, J. Lehtinen & T. Aila, "Improved precision and recall metric for assessing generative models," NeurIPS (2019).
  • G. Stein et al., "Exposing flaws of generative model evaluation metrics and their unfair treatment of diffusion models," NeurIPS (2023).
  • Z. Kadkhodaie, F. Guth, E. P. Simoncelli & S. Mallat, "Generalization in diffusion models arises from geometry-adaptive harmonic representations," ICLR (2024).