Quiz 2

Evaluation Metrics for Generative Models: FID, IS, Precision-Recall, and Diversity

4536 words
23 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Evaluation Metrics for Generative Models: FID, IS, Precision-Recall, and Diversity ## 🎯 Learning Objectives - Understand why evaluating generative models is fundamentally different from discriminative models - Compute and interpret Fréchet Inception Distance (FID) - Analyze the strengths and weaknesses of the Inc...

Evaluation Metrics for Generative Models: FID, IS, Precision-Recall, and Diversity

🎯 Learning Objectives

  • Understand why evaluating generative models is fundamentally different from discriminative models
  • Compute and interpret Fréchet Inception Distance (FID)
  • Analyze the strengths and weaknesses of the Inception Score (IS)
  • Evaluate generative models along precision and recall dimensions separately
  • Implement diversity metrics and detect mode collapse
  • Choose appropriate metrics for different generative model types (GANs, VAEs, Diffusion)

📋 Prerequisites

  • Generative Models Overview (Week 1): Understanding of what generative models produce
  • Basic statistics: Mean, variance, multivariate Gaussians, KL divergence
  • Image classification: Understanding of feature representations (e.g., from CNNs)

1. 📖 Core Content

1.1 Intuition: Why Can't We Just Use Accuracy?

In supervised learning, evaluation is straightforward: compute accuracy, precision, recall, F1 on a held-out test set. The model either predicts the right label or not. For generative models, the question is different: "How good are the generated samples?" This question has multiple dimensions:
  1. Fidelity: Do generated samples look realistic? (quality)
  2. Diversity: Do generated samples cover all modes of the data? (coverage)
  3. Novelty: Are generated samples new, or are they memorized training examples?
  4. Likelihood: How high is the probability assigned to held-out data? No single metric captures all four. Worse, some metrics can be gamed — a model that memorizes training data gets perfect fidelity but zero novelty.

1.2 Fréchet Inception Distance (FID)

The Fréchet Inception Distance (Heusel et al., 2017) is the most widely used metric for evaluating generative image models.

1.2.1 Intuition

Instead of comparing pixel values directly (which would be too strict — even a 1-pixel shift causes massive pixel-wise error), FID compares feature representations extracted from a pre-trained Inception-v3 network. The idea: two images that look similar should have similar Inception feature vectors (the 2048-dimensional activations from the last pooling layer). FID measures how different the distributions of these feature vectors are between real and generated images.

1.2.2 Formal Definition

Let the Inception features of real images be N(μr,Σr)\mathcal{N}(\mu_r, \Sigma_r) and of generated images be N(μg,Σg)\mathcal{N}(\mu_g, \Sigma_g). The Fréchet distance (also called Wasserstein-2 distance) between two multivariate Gaussians is:
FID=μrμg22+Tr(Σr+Σg2ΣrΣg)\text{FID} = \|\mu_r - \mu_g\|^2_2 + \text{Tr}\left(\Sigma_r + \Sigma_g - 2\sqrt{\Sigma_r \Sigma_g}\right)
where:
  • μr,Σr\mu_r, \Sigma_r: Mean and covariance of real image features
  • μg,Σg\mu_g, \Sigma_g: Mean and covariance of generated image features
  • Tr\text{Tr}: Trace of the matrix
  • ΣrΣg\sqrt{\Sigma_r \Sigma_g}: Matrix square root of ΣrΣg\Sigma_r \Sigma_g Lower FID is better (smaller distance between distributions).

1.2.3 Worked Example 1: Computing FID for Simple 2D Features

Suppose we have real images with features in 2D: μr=[2,3]\mu_r = [2, 3],
Σr=[10.50.52]\Sigma_r = \begin{bmatrix} 1 & 0.5 \\ 0.5 & 2 \end{bmatrix}
. Generated images have features: μg=[2.5,2.8]\mu_g = [2.5, 2.8],
Σg=[1.20.30.31.8]\Sigma_g = \begin{bmatrix} 1.2 & 0.3 \\ 0.3 & 1.8 \end{bmatrix}
. Step 1: Compute the squared mean difference:
μrμg2=(22.5)2+(32.8)2=0.25+0.04=0.29\|\mu_r - \mu_g\|^2 = (2-2.5)^2 + (3-2.8)^2 = 0.25 + 0.04 = 0.29
Step 2: Compute Tr(Σr+Σg)\text{Tr}(\Sigma_r + \Sigma_g):
Σr+Σg=[2.20.80.83.8]\Sigma_r + \Sigma_g = \begin{bmatrix} 2.2 & 0.8 \\ 0.8 & 3.8 \end{bmatrix} Tr(Σr+Σg)=2.2+3.8=6.0\text{Tr}(\Sigma_r + \Sigma_g) = 2.2 + 3.8 = 6.0
Step 3: Compute ΣrΣg\sqrt{\Sigma_r \Sigma_g}:
ΣrΣg=[10.50.52][1.20.30.31.8]=[1.351.21.23.75]\Sigma_r \Sigma_g = \begin{bmatrix} 1 & 0.5 \\ 0.5 & 2 \end{bmatrix} \begin{bmatrix} 1.2 & 0.3 \\ 0.3 & 1.8 \end{bmatrix} = \begin{bmatrix} 1.35 & 1.2 \\ 1.2 & 3.75 \end{bmatrix}
For the matrix square root, we compute eigendecomposition ΣrΣg=VΛVT\Sigma_r \Sigma_g = V \Lambda V^T: Eigenvalues: λ10.83\lambda_1 \approx 0.83, λ24.27\lambda_2 \approx 4.27
ΣrΣg=V[0.83004.27]VT\sqrt{\Sigma_r \Sigma_g} = V \begin{bmatrix} \sqrt{0.83} & 0 \\ 0 & \sqrt{4.27} \end{bmatrix} V^T
Step 4: Tr(ΣrΣg)0.83+4.270.91+2.07=2.98\text{Tr}(\sqrt{\Sigma_r \Sigma_g}) \approx \sqrt{0.83} + \sqrt{4.27} \approx 0.91 + 2.07 = 2.98 Step 5: FID = 0.29+6.02×2.98=0.29+6.05.96=0.330.29 + 6.0 - 2 \times 2.98 = 0.29 + 6.0 - 5.96 = 0.33 A low FID of 0.33 indicates the generated features closely match the real features.

1.2.4 Practical Guidelines for FID

FID RangeInterpretationTypical For
< 10ExcellentState-of-the-art GANs
10-30GoodDecent generative models
30-100ModerateEarly-stage models
> 100PoorUnrealistic samples
Important caveats:
  • FID requires many samples (typically 50K) for stable estimates
  • FID depends on the training set of the Inception network — it's biased toward ImageNet-like images
  • FID can be gamed by generating images with similar Inception features but different visual appearance
  • Small sample sizes produce unreliable FID estimates

1.3 Inception Score (IS)

The Inception Score (Salimans et al., 2016) was the predecessor to FID but is still widely used.

1.3.1 Intuition

A good generative model should produce images that:
  1. Contain clear objects: The Inception network confidently classifies them (low entropy of p(yx)p(y|x))
  2. Cover many classes: The generated set has diverse classes (high entropy of p(y)p(y)) IS combines these two desiderata.

1.3.2 Formal Definition

IS=exp(Expg[DKL(p(yx)p(y))])\text{IS} = \exp\left(\mathbb{E}_{x \sim p_g} \left[ D_{KL}\left(p(y|x) \| p(y)\right) \right]\right)
where:
  • p(yx)p(y|x) is the Inception network's label distribution for generated image xx
  • p(y)=Expg[p(yx)]p(y) = \mathbb{E}_{x \sim p_g}[p(y|x)] is the marginal label distribution
  • DKLD_{KL} is the KL divergence Equivalently:
IS=exp(H(p(y))Expg[H(p(yx))])\text{IS} = \exp\left(H(p(y)) - \mathbb{E}_{x \sim p_g}[H(p(y|x))]\right)
where HH is entropy. Higher IS is better.

1.3.3 Worked Example 2: Computing IS for Two Models

Model A generates only cats in 10 different poses. All images produce confident cat predictions (p(catx)0.9p(\text{cat}|x) \approx 0.9). The marginal distribution is p(y)=[0.9 cat,0.01 dog,0.01 car,...]p(y) = [0.9\text{ cat}, 0.01\text{ dog}, 0.01\text{ car}, ...].
ISA=exp(H(p(y))E[H(p(yx))])exp(lowlow)1.5IS_A = \exp(H(p(y)) - \mathbb{E}[H(p(y|x))]) \approx \exp(\text{low} - \text{low}) \approx 1.5
Model B generates cats, dogs, cars, and buildings equally. Each image is clearly of its class (p(classx)0.95p(\text{class}|x) \approx 0.95). Marginal p(y)p(y) is nearly uniform over 4 classes.
ISB=exp(higherlower)exp(1.390.22)3.2IS_B = \exp(\text{higher} - \text{lower}) \approx \exp(1.39 - 0.22) \approx 3.2
Model B has a higher IS because it produces diverse, high-confidence samples.

1.3.4 Limitations of IS

  1. No real-world reference: IS only looks at generated samples, comparing them to ImageNet classes. A model generating only one class per image but all classes equally gets a high IS regardless of whether images look real.
  2. Relies on Inception: Biased toward ImageNet-like images; doesn't work well for medical images, satellite imagery, etc.
  3. Insensitive to mode dropping: A model that generates only 10 out of 1000 ImageNet classes can still get a reasonable IS if those 10 classes are diverse.
  4. Doesn't detect overfitting: Memorized training images can get high IS.

1.4 Precision and Recall for Generative Models

Sajjadi et al. (2018) and Kynkäänniemi et al. (2019) proposed decomposing generative model quality into precision (fidelity) and recall (diversity).

1.4.1 Intuition

  • Precision: What fraction of generated images look realistic?
  • Recall: What fraction of real-data modes are covered by the generated distribution? A model that generates perfect cats but no dogs has high precision (cat images look real) but low recall (missing dog mode).

1.4.2 The Improvement over FID

FID combines precision and recall into a single number. Two models with the same FID could have very different precision-recall tradeoffs. Separating them provides more diagnostic information.

1.4.3 How It Works (Kynkäänniemi Method)

Step 1: For real data features ϕr\phi_r and generated features ϕg\phi_g, compute manifolds using k-nearest neighbors. Step 2: For each generated image, check if it falls within the real-data manifold. If yes, it's precise.
precision={generated samples in real-data manifold}all generated samples\text{precision} = \frac{|\{\text{generated samples in real-data manifold}\}|}{|\text{all generated samples}|}
Step 3: For each real image, check if it falls within the generated-data manifold. If yes, it's recalled.
recall={real samples in generated-data manifold}all real samples\text{recall} = \frac{|\{\text{real samples in generated-data manifold}\}|}{|\text{all real samples}|}

1.4.4 Worked Example 3: Precision-Recall Analysis

A dataset has 3 modes: cats, dogs, birds (each 1000 images). Model X: Generates 500 cat images and 500 dog images. All look realistic.
  • Precision: 1000/1000 = 1.0 (all generated look real)
  • Recall: The cat and dog modes are covered; the bird mode is not. So recall = 2/3 ≈ 0.67. Model Y: Generates 1000 images across all 3 modes, but 200 look unrealistic.
  • Precision: 800/1000 = 0.8 (200 unrealistic)
  • Recall: 1000/1000 = 1.0 (all real modes covered) Model Z: Generates only 1 image (a perfect cat), repeated 1000 times.
  • Precision: 1000/1000 = 1.0 (all look realistic)
  • Recall: 1/3 ≈ 0.33 (dog and bird modes missing) The precision-recall decomposition reveals these trade-offs that FID alone would mask.

1.5 Diversity Metrics

1.5.1 Perceptual Path Length (PPL)

PPL measures the smoothness of the generator's latent space. Interpolate between two random latents z1z_1 and z2z_2, and measure how much the generated images change per unit of interpolation.
PPL=E[1ϵ2d(G(lerp(z1,z2;t)),G(lerp(z1,z2;t+ϵ)))]\text{PPL} = \mathbb{E}\left[\frac{1}{\epsilon^2} d(G(\text{lerp}(z_1, z_2; t)), G(\text{lerp}(z_1, z_2; t+\epsilon)))\right]
where dd is perceptual distance (e.g., LPIPS) and lerp is linear interpolation. Lower PPL = smoother latent space = better semantic disentanglement.

1.5.2 Intra-Class Diversity

For conditional generation (e.g., class-conditional ImageNet), measure the average pairwise feature distance between generated images from the same class. Low intra-class diversity indicates mode collapse within a class.

1.6 Likelihood-Based Evaluation

For likelihood-based models (VAEs, autoregressive, normalizing flows), we can directly compute:
bits/dim=log2pθ(x)D\text{bits/dim} = -\frac{\log_2 p_\theta(x)}{D}
where DD is the dimensionality of xx (e.g., 3 × 256 × 256 for RGB images). Lower bits/dim is better. For reference:
  • PixelCNN++: ~2.92 bits/dim on CIFAR-10
  • Glow (normalizing flow): ~3.35 bits/dim on CIFAR-10
  • VAE: ~3.70 bits/dim on CIFAR-10 Important: Don't compare bits/dim across datasets. Also, bits/dim doesn't always correlate with perceptual quality — some models with good bits/dim produce poor-looking samples.

1.7 Metric Comparison Summary

MetricWhat It MeasuresRangeNeed Real Data?Can Be Gamed?
FIDFeature distribution distance0-∞ (lower better)YesPartially
Inception ScoreClassifiability + diversity1-1000 (higher better)NoYes
PrecisionFidelity of individual samples0-1 (higher better)YesYes
RecallCoverage of real data modes0-1 (higher better)YesNo*
Bits/dimLikelihood of test data-∞ to ∞ (lower better)Yes (test set)No
PPLLatent space smoothness0-∞ (lower better)NoPartially
*Recall is hard to game because generating diverse samples to cover all real modes is inherently difficult.

1.8 Best Practices

  1. Always report multiple metrics: FID + Precision-Recall + IS covers quality, diversity, and real-world correspondence.
  2. Use sufficient samples: FID with < 10K samples is unreliable. 50K is standard.
  3. Control for model seed: Different random seeds can produce different FIDs. Report mean + std over multiple runs.
  4. Don't compare across papers directly: Implementation details (number of samples, preprocessing, feature extraction layer) vary. Always compare within your own setup.
  5. Check for memorization: Use nearest-neighbor analysis to ensure generated images aren't just training set copies.
  6. Use dataset-specific metrics: For non-ImageNet datasets, use a feature extractor fine-tuned on that domain.

1.9 Why This Matters

Choosing the right evaluation metric determines which research direction looks promising. The history of GANs shows how the wrong metric (IS) favored models with high class diversity (BigGAN) but didn't penalize low intra-class diversity. FID + Precision-Recall became the standard because they catch mode collapse better. For your own projects:
  • Comparing GAN variants: FID + Precision-Recall (best overall)
  • Debugging training: Precision-Recall helps identify whether quality or diversity is the problem
  • Production deployment: FID + human evaluation (metrics alone aren't enough)
  • Academic research: FID + IS + bits/dim (if applicable) + precision-recall

2. 📐 Key Formulas / Concepts

MetricFormulaWhat It Captures
FID$\\mu_r - \mu_g\
IS$\exp(\mathbb{E}_x[KL(p(y\x)\
Precision${g \in \mathcal{G} : g \in \text{manifold}(\mathcal{R})}
Recall${r \in \mathcal{R} : r \in \text{manifold}(\mathcal{G})}
Bits/dimlog2pθ(x)/D-\log_2 p_\theta(x) / DCompression-based quality

3. ⚠️ Common Pitfalls

Pitfall 1: Using FID with Too Few Samples

Mistake: Computing FID with 1000 generated images and 5000 real images. Why: The covariance matrix estimate becomes very noisy with few samples. In 2048-dimensional Inception space, you need at least 2048 samples just for a full-rank covariance, and typically 10-50K for a stable estimate. How to detect: If running FID multiple times on different subsets gives wildly different values, your sample size is too small. Correct approach: Use at least 10K samples for preliminary results, 50K for publication-standard results.

Pitfall 2: Using Inception Score for Non-ImageNet Domains

Mistake: Computing IS for medical images, satellite images, or artistic styles. Why: The Inception network was trained on ImageNet (1000 object classes). When it sees images of cells or landscapes, its label distribution p(yx)p(y|x) is meaningless (it assigns high confidence to the nearest ImageNet class, which may be unrelated). Correct approach: Either (a) fine-tune a classifier on the target domain and use it instead of Inception, or (b) use FID with a feature extractor trained on domain-relevant data.

Pitfall 3: Relying Solely on FID for Model Selection

Mistake: Selecting the checkpoint with the lowest FID and ignoring other metrics. Why: FID can be minimized by generating feature statistics that happen to match the real data, even if individual samples look unrealistic. Low FID doesn't guarantee high precision; it only guarantees similar aggregate statistics. Correct approach: Check FID + IS + precision-recall + qualitative inspection. Always look at actual generated samples.

Pitfall 4: Comparing FIDs Across Different Preprocessing Pipelines

Mistake: Comparing your FID of 15 with a paper's FID of 10, concluding your model is worse. Why: FID computation is sensitive to:
  • Which layer of Inception is used (pool3 vs. logits)
  • Image preprocessing (resizing method, normalization)
  • Number of samples
  • Which real-data reference set is used Correct approach: Reproduce the exact evaluation setup from the paper you're comparing against. When reporting your own, specify all implementation details.

Pitfall 5: Ignoring Memorization When Reporting Likelihood

Mistake: Reporting a very low bits/dim on the test set without checking for memorization. Why: A model with strong memory capacity (e.g., autoregressive model with many parameters) can achieve excellent bits/dim by effectively compressing the training set, not by learning generalizable features. Correct approach: Check nearest-neighbor distances between generated and training images. If generated images have training-set neighbors with distance near zero, the model is memorizing.

4. 📝 Practice Questions

Q1: A GAN generates 50,000 images of faces. Compute FID: μg=[0.5,0.2]\mu_g = [0.5, -0.2], Σg=[1.1,0.1],[0.1,0.9](/courses/bsda5002/notes/1.1\Sigma_g = [1.1, 0.1], [0.1, 0.9](/courses/bsda5002/notes/1.1%2C%200.1%5D%2C%20%5B0.1%2C%200.9). Real data: μr=[0.3,0.1]\mu_r = [0.3, 0.1], Σr=[1.0,0.0],[0.0,1.0](/courses/bsda5002/notes/1.0\Sigma_r = [1.0, 0.0], [0.0, 1.0](/courses/bsda5002/notes/1.0%2C%200.0%5D%2C%20%5B0.0%2C%201.0). Calculate FID.
Step 1: μrμg2=(0.30.5)2+(0.1+0.2)2=0.04+0.09=0.13\|\mu_r - \mu_g\|^2 = (0.3-0.5)^2 + (0.1+0.2)^2 = 0.04 + 0.09 = 0.13
Step 2: Tr(Σr+Σg)=Tr([2.1,0.1],[0.1,1.9](/courses/bsda5002/notes/2.1\text{Tr}(\Sigma_r + \Sigma_g) = \text{Tr}([2.1, 0.1], [0.1, 1.9](/courses/bsda5002/notes/2.1%2C%200.1%5D%2C%20%5B0.1%2C%201.9)) = 2.1 + 1.9 = 4.0
Step 3: ΣrΣg=[1.0,0.0],[0.0,1.0](/courses/bsda5002/notes/1.0\Sigma_r \Sigma_g = [1.0, 0.0], [0.0, 1.0](/courses/bsda5002/notes/1.0%2C%200.0%5D%2C%20%5B0.0%2C%201.0) \times [1.1, 0.1], [0.1, 0.9](/courses/bsda5002/notes/1.1%2C%200.1%5D%2C%20%5B0.1%2C%200.9) = [1.1, 0.1], [0.1, 0.9](/courses/bsda5002/notes/1.1%2C%200.1%5D%2C%20%5B0.1%2C%200.9)
Step 4: Compute eigenvalues: (1.1λ)(0.9λ)0.01=λ22λ+0.990.01=λ22λ+0.98=0(1.1-\lambda)(0.9-\lambda) - 0.01 = \lambda^2 - 2\lambda + 0.99 - 0.01 = \lambda^2 - 2\lambda + 0.98 = 0
λ=2±43.922=2±0.082=2±0.2832\lambda = \frac{2 \pm \sqrt{4 - 3.92}}{2} = \frac{2 \pm \sqrt{0.08}}{2} = \frac{2 \pm 0.283}{2}
λ1=1.1415\lambda_1 = 1.1415, λ2=0.8585\lambda_2 = 0.8585
Step 5: Tr(ΣrΣg)=1.1415+0.8585=1.068+0.927=1.995\text{Tr}(\sqrt{\Sigma_r \Sigma_g}) = \sqrt{1.1415} + \sqrt{0.8585} = 1.068 + 0.927 = 1.995
Step 6: FID = 0.13+4.02(1.995)=0.13+4.03.99=0.140.13 + 4.0 - 2(1.995) = 0.13 + 4.0 - 3.99 = 0.14
Very low FID (0.14) — the generated distribution closely matches the real one. Q2: A model generates 5 dog breeds out of 100 ImageNet classes equally, with avg confidence of 0.95 per generated image. Another generates all 100 classes equally but with avg confidence of only 0.3. Which has higher IS?
Model A (5 breeds, high confidence):
  • H(p(y))H(p(y)): Uniform over 5 classes → log(5)1.61\log(5) \approx 1.61 nats
  • E[H(p(yx))]\mathbb{E}[H(p(y|x))]: Per-image entropy ≈ (0.95log(0.95)+0.05log(0.05/99)...)-(0.95\log(0.95) + 0.05\log(0.05/99)...) ≈ very low ≈ 0.3 nats
  • KL = 1.610.3=1.311.61 - 0.3 = 1.31
  • IS = exp(1.31)3.7\exp(1.31) \approx 3.7
Model B (100 classes, low confidence):
  • H(p(y))H(p(y)): Uniform over 100 classes → log(100)4.61\log(100) \approx 4.61 nats
  • E[H(p(yx))]\mathbb{E}[H(p(y|x))]: Per-image entropy ≈ (0.3log(0.3)+0.7log(0.7/99)...)-(0.3\log(0.3) + 0.7\log(0.7/99)...) ≈ 2.8 nats
  • KL = 4.612.8=1.814.61 - 2.8 = 1.81
  • IS = exp(1.81)6.1\exp(1.81) \approx 6.1
Model B has higher IS despite lower per-image confidence, because it covers more diverse classes. The IS favors diversity very strongly — this is both a strength and a weakness. Q3: A model produces perfect samples of 8 out of 10 real data modes. The other 2 modes are completely missing. Do precision and recall capture this?
  • Precision: All generated samples look realistic (they only come from the 8 modes the model learned). Precision ≈ 1.0.
  • Recall: Only 8 out of 10 real modes are covered. Recall ≈ 0.8.
FID would be moderately good (features match well on 8/10 modes but the missing 2 contribute to mean/covariance difference). The precision-recall decomposition reveals that the model has a coverage problem (low recall) that FID alone doesn't clearly indicate.
If the missing 2 modes are small (few training examples), FID might barely penalize the model, while recall catches it by checking whether real-data points lie in the generated-data manifold. Q4: Why does FID use the Inception network's pooling layer (2048-d features) instead of the logits (1000-d class probabilities)?
The pooling layer preserves spatial and structural information that the logits discard. Logits collapse the representation to class probabilities, losing information such as:
  • Object pose, orientation, and position
  • Background characteristics
  • Fine-grained textures that aren't class-discriminative
Using the pooling layer's 2048-dimensional feature vector captures more of these visual characteristics, making FID more sensitive to visual quality differences that don't affect classifiability.
For example, two cat images (both classified as "tabby cat" with 0.95 confidence) could have very different visual quality — blurry vs sharp — which the pooling layer features reflect but logits don't. Q5: You train a VAE and get bits/dim = 3.5 on CIFAR-10 test set. What does this mean in terms of compression?
Bits/dim measures how many bits on average are needed to encode each dimension (here, each color channel of each pixel) under the model. A bits/dim of 3.5 means:
  • Per pixel (3 color channels): 3×3.5=10.53 \times 3.5 = 10.5 bits
  • Per 32×32 image: 32×32×10.5=1075232 \times 32 \times 10.5 = 10752 bits ≈ 1.34 KB
For comparison:
  • Uncompressed PNG: ~3-16 bits/pixel (~9-48 KB for CIFAR-10)
  • State-of-the-art compression (BPG): ~0.5-2 bits/pixel
The model compresses CIFAR-10 images to about 1.34 KB each on average under the lossless coding scheme derived from the model. A lower bits/dim means the model better captures the data distribution, achieving higher compression. Q6: Explain why the Inception Score doesn't require real data while FID does. What are the consequences?
IS only uses generated data: It computes p(yx)p(y|x) (Inception distribution for each generated image) and p(y)p(y) (marginal over all generated images). No real data is needed.
FID requires both real and generated data: It compares feature distributions between the two.
Consequences:
  • IS can be computed without access to the training set (useful for evaluating models trained on private data)
  • IS doesn't penalize "unrealistic but classifiable" images — a generated image could look nothing like a real image but still get high IS if the Inception network confidently classifies it
  • IS is blind to certain failure modes: a model generating only 5 of 1000 classes can get good IS
  • FID is more robust because it directly compares to real data, but requires access to real data statistics
The best practice is to use both: IS as a measure of intra-sample quality + diversity, FID as a measure of distributional match to real data. Q7: You're developing a generative model for medical X-ray images. What evaluation metrics would you use and why?
Not recommended for this domain:
  • Inception Score: The Inception network is trained on ImageNet (natural images). X-ray images don't match any ImageNet class, so IS would be meaningless.
  • FID with standard Inception: Same issue — Inception features don't capture medically relevant features.
Recommended:
  1. Domain-specific FID: Fine-tune a feature extractor (e.g., ResNet-50) on a large X-ray dataset (e.g., CheXpert). Use its penultimate layer features for FID computation.
  2. Precision-Recall: Using the domain-specific features — especially important for medical imaging where some pathologies (modes) are rare.
  3. Freight check by domain experts: Metrics for medical images must correlate with clinical utility. Have radiologists evaluate generated images for diagnostic consistency.
  4. Diagnostic utility metric: Train a downstream classifier (e.g., pneumonia detector) on real + generated data and measure if generated data improves classifier performance.
Critical consideration: In medical imaging, generating a plausible but incorrect X-ray could be dangerous. FID and IS don't catch radiologically meaningful errors. Always include human expert evaluation. Q8: How can you detect whether a generative model is memorizing training data rather than generalizing?
MethodHow It WorksWhat to Look For
Nearest neighborFor each generated image, find its nearest neighbor in the training set (pixel or feature distance)If average distance is very small (~0), model is memorizing
Train-test likelihood gapCompare training and test set bits/dimIf training bits/dim is much lower than test bits/dim, model is overfitting/memorizing
Membership inferenceTrain a classifier to distinguish generated images from held-out test imagesIf classifier can easily tell them apart, the model has memorized training set specifics
Data interpolationGenerate images that should interpolate between two training examplesIf interpolated images look like exact training examples, memorization is happening
A healthy generative model should have:
  • Generated test nearest neighbors that are visually similar but not identical
  • Training and test bits/dim within a small gap (e.g., < 10% difference)
  • Generated images that humans can't systematically distinguish from unseen real data Q9: A diffusion model achieves FID=8.0 while a GAN achieves FID=6.5 on the same dataset. Can we conclude the GAN is better?
Not definitively. FID is one metric among many, and several factors complicate direct comparison:
  1. FID variance: FID has stochasticity from sampling. With 50K samples, a difference of 1.5 FID points may or may not be statistically significant. Bootstrap confidence intervals should be computed.
  2. Precision-Recall tradeoff: The GAN might have better aggregate FID but lower recall (missing some modes), while the diffusion model might have better coverage.
  3. Other metrics: Check IS, precision-recall, human evaluation. A diffusion model with slightly worse FID might produce more clinically acceptable samples.
  4. Application context: For creative tools, you might prefer the GAN's sharper images. For scientific applications requiring diversity, you might prefer the diffusion model.
  5. Computational cost: The diffusion model might require 1000 steps vs. the GAN's 1 step. In a resource-constrained setting, the GAN might be practically superior despite a small FID disadvantage.
Always use multiple metrics and inspect samples visually before drawing conclusions. Q10: Explain the concept of "manifold" in precision-recall evaluation for generative models.
In precision-recall for generative models, the manifold is the set of feature vectors that represent the "typical" data points. It's estimated from samples:
Real-data manifold: The region in feature space where real data points fall. Computed by:
  1. For each real data point, find its k nearest neighbors among real data
  2. The manifold is the union of hyperspheres with radius = distance to the k-th neighbor
Generated-data manifold: Same procedure but for generated data points.
Precision = fraction of generated points that fall inside the real-data manifold.
  • High precision means generated samples have features similar to real data
  • Low precision means generated samples have "unrealistic" features
Recall = fraction of real data points that fall inside the generated-data manifold.
  • High recall means the generator covers all regions where real data exists
  • Low recall means some real data regions are not covered (mode dropping)
This approach implicitly handles multi-modal distributions because each data point has its own nearest-neighbor distance, which adapts to local data density. Q11: Why does FID sometimes improve when you train a model longer, even though sample quality appears to degrade visually?
This is known as the FID-quality mismatch and can happen for several reasons:
  1. Feature space collapse: The model learns to generate features that match the aggregate statistics (mean + covariance) of real data in Inception space without generating visually realistic samples. Think of it as "cheating" on the FID exam by matching features rather than images.
  2. Inception bias: The Inception network focuses on class-discriminative features. A model could learn to produce good class-specific features while generating implausible textures or backgrounds.
  3. Overfitting to FID: If you select checkpoints based on FID, you're optimizing toward FID. The FID landscape might not perfectly correlate with human perceptual quality.
To detect this: always inspect generated samples visually alongside FID. If FID improves but visual quality degrades, there's a problem with your evaluation setup. In such cases, use precision-recall to check if the FID improvement comes from better recall (more coverage) but worse precision (lower individual quality). Q12: You have a model with precision=0.85 and recall=0.60. Propose two strategies to improve each.
To improve precision (0.85 → higher):
  1. Reduce truncation: If using a truncation trick (common in StyleGAN), increase the truncation parameter ψ (e.g., from 0.7 to 0.5). This reduces variation but improves per-sample quality by sampling closer to the mean of the latent distribution.
  2. Increase discriminator capacity (if GAN): A stronger discriminator forces the generator to produce more realistic samples, improving precision at the potential cost of recall.
  3. Tune training hyperparameters: Lower learning rate, increase gradient penalty coefficient (WGAN-GP), or adjust regularization to reduce training instability that causes bad samples.
To improve recall (0.60 → higher):
  1. Increase latent dimension: More noise dimensions can help the generator cover more modes.
  2. Reduce truncation: If using truncation, decrease ψ (e.g., from 0.7 to 1.0). This allows more variation but may introduce lower-quality samples.
  3. Data augmentation: Use more aggressive augmentation to prevent the generator from focusing on a subset of modes.
  4. Re-balance GAN training: If the discriminator is too strong, it may prevent the generator from exploring new modes. Weaken the discriminator (dropout, fewer parameters) to give the generator more freedom.
  5. Use a mixture model: Instead of a single generator, use multiple generators specializing in different modes.
Typically, precision and recall have an inverse relationship — improving one often harms the other. The goal is to find the right balance for your application.

5. 🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.