Evaluating generative models is fundamentally different from discriminative tasks because there's no single "correct" output—we care about quality (realism) and diversity (coverage of the data distribution). Traditional metrics like accuracy don't apply, so we use specialized scores: Inception Score (IS) and Fréchet Inception Distance (FID).
The first term is −H(y∣x) (negative conditional entropy), the second simplifies because Ex[∑yp(y∣x)logp(y)]=∑yp(y)logp(y)=−H(y).
So: KLavg=H(y)−H(y∣x)
Higher H(y) (diverse labels) and lower H(y∣x) (confident predictions) → higher IS.
Step 4: Exponentiate for interpretability
IS=exp(KLavg)
Why exponentiate? To convert from log-space to a scale where higher = better, and to make it match "effective number of classes" intuition. IS≈ 1 means terrible (all images look the same or are noise), IS ≈ number of classes means perfect.
FID measures the distance between the distribution of real images and generated images in the feature space of Inception-v3. Lower FID = distributions are closer = better generation.
The term (ΣrΣg)1/2 is computed via eigenvalue decomposition:
If ΣrΣg=UΛUT, then (ΣrΣg)1/2=UΛ1/2UT
Why? Because for positive semi-definite matrices, the square root is well-defined.
Step 4: Trace of the difference
Tr(Σr+Σg−2(ΣrΣg)1/2)
Why trace? It sums the covariance mismatch across all 2048 dimensions. The −2(ΣrΣg)1/2 term is a geometric mean that penalizes covariance structure differences.
| Metric | Measures | Pros | Cons | Best For |
|--------|-------|------|----------|
| IS | Quality & diversity (without reference) | Fast, no real data needed | Doesn't detect mode collapse, biased toward ImageNet classes | Quick sanity check, unconditional generation |
| FID | Distribution match to real data | Catches mode collapse, aligns with human judgment | Requires real data, expensive to compute | Final evaluation, comparing models |
GAN Training Dynamics: These metrics guide GAN training—collapse shows in FID drop.
Inception-v3 Architecture: Understanding the feature extractor clarifies why these metrics work.
Mode Collapse in GANs: FID is the primary tool for detecting this failure mode.
Precision and Recall for Generative Models: Newer metrics that decompose FID into quality (precision) and coverage (recall).
Perceptual Loss Functions: Similar idea—use pre-trained networks to measure perceptual similarity.
Recall Explain to a 12-Year-Old
Imagine you're a teacher grading art students. You want their drawings to be:
Good (they look like real things)
Diverse (not everyone draws the same tree)
But you can't look at thousands of drawings yourself, so you train a robot judge (Inception network) that learned what "good art" looks like.
Inception Score (IS): You show the robot one drawing. If it says "that's definitely a dog!" (confident), the drawing is clear. If it sees all kinds of things across many drawings (dogs, cats, cars), that's diverse. High IS = confident + diverse.
FID: You have real photos and student drawings. You ask the robot to describe both sets (without saying "dog" or "cat," just internal descriptions like "pointy," "fluffy"). Then you measure: how similar are the two description clouds? Small distance = the drawings look like real photos.
Why both? IS just checks clarity. FID checks if students are drawing the right things (a perfect drawing of a dragon doesn't match "photos of cats").
#flashcards/ai-ml
What problem does Inception Score (IS) solve? :: Automatic evaluation of generative models without manual inspection, measuring both quality (sharpness) and diversity of generated samples using a pre-trained classifier.
What are the two properties IS checks?
1) Quality: individual samples should have low-entropy p(y|x) (confident predictions), 2) Diversity: marginal p(y) should have high entropy (all classes represented).
Write the Inception Score formula :: IS = exp(E_x[D_KL(p(y|x) || p(y))]) where p(y|x) is the classifier's prediction for generated image x, and p(y) is the average class distribution.
Why do we exponentiate the KL divergence in IS?
To convert from log-space to an interpretable scale where higher is better, and to match "effective number of classes" intuition (IS ≈ number of classes for perfect generation).
What is the main limitation of Inception Score?
It cannot detect mode collapse—a model generating perfect samples from only one mode can achieve high IS because p(y|x) is still confident, even though diversity is low.
What does FID measure?
The distance between the distribution of real image features and generated image features in Inception-v3's feature space, specifically the Fréchet distance assuming both are Gaussian.
Write the FID formula
FID = ||μ_r - μ_g||² + Tr(Σ_r + Σ_g - 2(Σ_r Σ_g)^(1/2)) where μ and Σ are the mean and covariance of real (r) and generated (g) features.
What are the two components of FID?
1) Mean difference ||μ_r - μ_g||² measuring distribution shift, 2) Covariance term Tr(Σ_r + Σ_g - 2(Σ_r Σ_g)^(1/2)) measuring shape/spread mismatch.
Why use Inception-v3 features instead of raw pixels?
Inception features capture semantic properties (textures, object parts) that align with human perception, unlike pixel-space where small shifts cause large distances despite perceptual similarity.
Can you compare FID scores across different datasets?
No, FID is dataset-dependent because intrinsic complexity varies (MNIST vs CelebA) and Inception's feature space may be better suited to some data types than others.
What does FID = 0 mean?
The generated and real distributions are identical in feature space—but this could mean the model memorized training data (overfitting) rather than true generalization.
Why is FID better than IS for detecting mode collapse?
FID compares to real data distribution, so if the generator mises modes present in real data, the covariance Σ_g won't match Σ_r and FID will be high.
What layer of Inception-v3 is used for FID?
The pool3 layer (2048-dimensional feature vectors) before the final classification layer, capturing high-level semantic features.
How many samples are typically used for computing FID?
At least 10,000 samples from both real and generated distributions to get stable covariance estimates.
Why does IS use KL divergence specifically?
KL divergence naturally captures the relationship between conditional p(y|x) and marginal p(y)—it's large when individual samples are confident (low H(y|x)) but the overall distribution is diverse (high H(y)).
What is the trace operation in FID?
Tr(A) sums the diagonal elements of matrix A, representing the total variance across all 2048 feature dimensions in this context.
Why do we need (Σ_r Σ_g)^(1/2) in FID?
The matrix square root provides the geometric mean of covariances, creating a symmetric distance that properly accounts for correlation structure differences between distributions.
What does high IS with high FID indicate?
Generated images are individually sharp and cover many classes (high IS) but don't match the real data distribution (high FID)—possible if generating plausible but wrong samples.
What does low IS with low FID indicate?
This is contradictory and unlikely—low IS means blurry or mode-collapsed samples, which shouldn't match real data well. Suggests an evaluation error.
What metric complements FID to separate quality from diversity?
Precision and Recall for generative models—precision measures sample quality (no outliers), recall measures mode coverage (distribution support).
Dekho yaar, generative models ko evaluate karna discriminative tasks se bilkul different hai. Jaise classification mein hum simply accuracy check kar sakte hain kyunki wahan ek "correct" answer hota hai. Lekin jab model naye images generate karta hai, wahan koi single correct output nahi hota. Toh hum do cheezein check karte hain: quality (matlab images kitni realistic dikhti hain) aur diversity (model saare types ke images bana raha hai ya sirf ek hi cheez repeat kar raha hai). Yeh manually thousands of images dekh ke judge karna impossible hai, isliye hum automated metrics use karte hain jaise Inception Score (IS) aur FID.
Ab core intuition samajho: dono metrics ek pre-trained classifier (Inception-v3) ko ek "smart judge" ki tarah use karte hain jo already high-level features samajhta hai jo humans ko matter karti hain. IS ka funda simple hai — agar tumhare generated image ko classifier confidently pehchaan le (jaise "yeh 90% dog hai"), toh iska matlab image sharp aur meaningful hai, yaani good quality. Aur agar tumhare saare images milke har class cover karte hain (kabhi dog, kabhi cat, kabhi car), toh diversity achhi hai. Mathematically yeh KL divergence se capture hota hai: jab conditional distribution p(y∣x) peaked ho (confident prediction) aur overall marginal p(y) uniform ho (variety), tab IS high aata hai. Bas end mein exponentiate kar dete hain taaki number interpret karna easy ho jaaye.
Yeh cheez matter kyun karti hai? Kyunki jab tum GANs ya diffusion models train kar rahe ho, tumhe har checkpoint pe pata hona chahiye ki model improve ho raha hai ya nahi, aur alag-alag models ko fairly compare karna hai. Bina reliable metric ke tum bas guess karte rahoge. FID toh IS se bhi behtar mana jaata hai kyunki woh real aur generated images ke feature distributions ke beech distance measure karta hai — lower FID matlab better. Toh basically yeh metrics tumhare generative model ki report card hain jo objectively batati hai ki tumhara model kitna achha kaam kar raha hai.