Fréchet Inception Distance
Why generative models are hard to compare, and how FID compares real and generated images through Gaussians fitted to Inception features.
How to judge a model
The topic Inception Score judged a generator by its samples alone, through a frozen Inception network. But no real image ever entered its formula, so it could not notice a model that copies its training set, and it rewarded ImageNet's classes rather than resemblance to the data. This topic keeps the network as a fixed ruler and adds what was missing: a set of real images to compare against.
Why not return to the average log-likelihood of held-out images instead? That topic gave the first reason: not every model has one. A GAN has no likelihood at all; VAEs and ordinary DDPM usually give an ELBO — a lower bound, not the value itself. Exact likelihood comes from flows and autoregressive models, and also from the continuous-time probability-flow ODE (Continuous-time diffusion and flow matching), where is an integral of a divergence rather than a DDPM ELBO. The second reason is worse.
It barely tracks sample quality (Theis, van den Oord and Bethge, 2016). Take a good model and mix it with noise: with probability draw from , otherwise output noise from . The mixture's density is at least times that of , so
With , 99 samples out of 100 are noise, yet the log-likelihood drops by at most a small constant. One color image at 3 bits per dimension takes about nats, so the drop is invisible. The reverse also happens: a model that memorizes its training set draws perfect samples and gives zero density to every new image.
So we want a score computed from samples alone, compared against real images, that agrees with what a person sees.
Features, not pixels
We compare two sets of images: real ones and generated ones. Pixel space is a poor place to do it. Shift a photo by one pixel and its Euclidean distance to the original becomes large, though nothing in the picture has changed. Two different patches of grass, meanwhile, may land close together.
The Fréchet Inception Distance, FID (Heusel et al., 2017), compares images through the eyes of a classifier. It takes Inception-v3 (Szegedy et al., 2016), trained on ImageNet and then frozen. Every image is resized to , passed through the network, and read off at the last pooling layer, just before the classification head:
These 2048 features describe objects, textures and layout. Earlier layers stay close to pixels. The 1000 class probabilities at the very end keep too little: they say "dog", not what the dog looks like. (The Inception Score of the previous topic used exactly those probabilities.)
The network never sees our training data. It is a fixed ruler, the same for every model being compared.
A Gaussian for each cloud
Pass real images and generated images through the network. We get two clouds of points in . FID summarizes each cloud by its mean and covariance (see Multivariate Gaussians). For the real cloud,
and , are computed the same way from the generated cloud. Each cloud is then treated as a Gaussian, and .
Why only two moments? Inception features are bounded, and two bounded distributions that agree in every moment are equal; Heusel et al. keep just the first two. Why a Gaussian? Among all distributions with a given mean and covariance, it has the largest entropy. It assumes nothing beyond those two moments. It also has a closed-form distance, which the next block uses.
Note what is not compared. Real image is never paired with generated image , and no class labels are used. FID compares the two sets as wholes.
The price is size. A covariance is a big object to estimate from samples, and we will come back to that.
The Fréchet distance
We need a distance between two Gaussians. Wasserstein GANs and Lipschitz constraints defined as the cost of the cheapest transport plan, paying per unit of mass. Paying the squared distance instead gives the 2-Wasserstein distance:
For general distributions it is intractable. Between two Gaussians it has a closed form (Dowson and Landau, 1982), also called the Fréchet distance. The reason is that the cost of a plan depends on it only through means and covariances. Write and with centered , , and let be their cross-covariance. Expanding the square,
The cross term with the means drops out because has mean zero, and . So the best plan correlates and as strongly as the two covariances allow. The largest reachable is (the note derives it with a singular value decomposition). FID is the resulting minimum for the two fitted Gaussians:
The first term is the squared distance between the centers of the clouds. In the WGAN topic, shifting a distribution by cost ; with squared cost it costs .
The second term compares the shapes of the clouds. is a matrix square root, a matrix whose square is ; its trace is the sum of the square roots of the eigenvalues of . These eigenvalues are positive, because is similar to the symmetric positive definite matrix . The term is never negative: it is the smallest reachable . It is zero only when the best plan sets , which forces . In code:
from scipy import linalg
covmean = linalg.sqrtm(S_r @ S_g).real
fid = ((mu_r - mu_g) ** 2).sum() + np.trace(S_r + S_g - 2 * covmean)FID is the squared distance. Lower is better. Zero means equal means and covariances, not identical feature distributions.
FID in one dimension
With a single feature, every matrix becomes a number, and the formula falls apart into two squares:
Means are compared with means, standard deviations with standard deviations. Take real features and generated ones . The mean term is , the spread term is , and .
The spread term is symmetric. A generator that is too spread out pays, and so does one that is too narrow, by the same rule.
In many dimensions small errors add up. Suppose every feature had unit variance and the generator shrank each one to of its spread. Each coordinate adds , and 2048 coordinates add .
What one number hides
FID compresses everything into one number. Three things slip through.
Fidelity and diversity are mixed. A poor FID can mean unrealistic samples (low fidelity) or realistic samples that cover only part of the data (low diversity, as in mode collapse). FID cannot say which. Precision and recall separate the two (Sajjadi et al., 2018; Kynkäänniemi et al., 2019). In the same feature space, draw a ball around each real feature that reaches its -th nearest real neighbor. Precision is the share of generated samples that fall inside the real balls: are the samples realistic? Recall swaps the roles: the share of real samples inside balls around generated ones. Is the data covered?
Only two moments count. Real features are not Gaussian. Two feature distributions with different shapes but the same mean and covariance get FID (Jayasumana et al., 2024).
Copies are invisible. A model that returns its training images reproduces the real statistics and scores close to . Nothing in FID asks for novelty. Catching copies needs a per-image check, such as a nearest-neighbor search in the training set.
Sample size and the fine print
FID is estimated from finite samples, and the estimate is biased upward: averaged over repeated samples, it lies above the true FID, although a single estimate can land on either side of a true value above . Even two sets drawn from the same distribution get a positive score, since every estimate is itself a squared distance between two fitted Gaussians. The estimated means differ by noise, and the mean term alone averages . The covariance has over two million free numbers; with images its estimate is singular.
The bias shrinks roughly like , and its size depends on the generator (Chong and Forsyth, 2020). So two models can swap places when changes. The common practice is to compare only at the same , usually generated images, as in Heusel et al. (2017). That makes the numbers comparable but does not remove the bias: two models at the same can still be ranked by their bias rather than their quality, and Bińkowski et al. (2018) build a 2048-dimensional case where even samples give the wrong order. Chong and Forsyth extrapolate the estimate in to .
Bińkowski et al. also propose a score with no bias at all, the Kernel Inception Distance (KID). It keeps the Inception features and drops the Gaussian fit. With the kernel on -dimensional features, KID is the squared maximum mean discrepancy
where are independent real features and independent generated ones. Expanding the cube shows that it compares the moments up to order three. It is estimated by averaging over pairs of samples, leaving out each sample paired with itself. Then every average is unbiased, and so is the estimate, at any ; for two identical distributions it sometimes comes out slightly negative, as an unbiased estimate of must. No estimator of FID is unbiased for all distributions, whatever the sample size.
The pipeline matters as much. The resizing filter, JPEG compression of saved samples, and the exact Inception weights all change the score (Parmar, Zhang and Zhu, 2022), sometimes by more than the gaps between models in a paper. Their clean-fid library fixes one careful pipeline. The features also carry ImageNet's habits. FID can drop when generated images match ImageNet class statistics better, with no visible gain (Kynkäänniemi et al., 2023). Inception-based FID also underrates diffusion models compared with human judgment, and Stein et al. (2023) suggest DINOv2 features instead.
A good report states , the reference set and the implementation, averages over a few seeds, and shows precision, recall and samples next to the FID.
Even a carefully reported FID is still one number, and its first blind spot costs the most: a model that has lost diversity and a model that has lost fidelity can get the same score. The next topic, Precision and recall for generative models, shows how completely FID mixes the two failures and builds a separate number for each.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Go deeper — optional
Code and labs do not count toward the main percentage or the certificate.
- FID from 1D moments of two Gaussiansoptional
Analytic FID=(Δμ)²+(Δσ)² and an empirical estimate. Self-check in the notebook.
~15 min · easier on a computer · The FID topic read.
Self-check in the notebook — not part of mastery or the certificate.
Answers are saved on the server and tied to this browser until you sign in.