Skip to content
BIASED

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 log⁡p0\log p_0 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 QQ and mix it with noise: with probability ww draw from QQ, otherwise output noise from QnoiseQ_{\text{noise}}. The mixture's density is at least ww times that of QQ, so

log⁡(w Q(x)+(1−w) Qnoise(x))≥log⁡w+log⁡Q(x).\log\big(w\, Q(x) + (1 - w)\, Q_{\text{noise}}(x)\big) \ge \log w + \log Q(x).

With w=0.01w = 0.01, 99 samples out of 100 are noise, yet the log-likelihood drops by at most a small constant. One 32×3232 \times 32 color image at 3 bits per dimension takes about 64006400 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 299×299299 \times 299, passed through the network, and read off at the last pooling layer, just before the classification head:

x  ↦  h(x)∈R2048.x \;\mapsto\; h(x) \in \mathbb R^{2048}.

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 NrN_r real images and NgN_g generated images through the network. We get two clouds of points in R2048\mathbb R^{2048}. FID summarizes each cloud by its mean and covariance (see Multivariate Gaussians). For the real cloud,

μr=1Nr∑i=1Nrh(xi),Σr=1Nr−1∑i=1Nr(h(xi)−μr)(h(xi)−μr)⊤,\mu_r = \frac{1}{N_r} \sum_{i=1}^{N_r} h(x_i), \qquad \Sigma_r = \frac{1}{N_r - 1} \sum_{i=1}^{N_r} \big(h(x_i) - \mu_r\big)\big(h(x_i) - \mu_r\big)^\top,

and μg\mu_g, Σg\Sigma_g are computed the same way from the generated cloud. Each cloud is then treated as a Gaussian, N(μr,Σr)\mathcal N(\mu_r, \Sigma_r) and N(μg,Σg)\mathcal N(\mu_g, \Sigma_g).

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 ii is never paired with generated image ii, and no class labels are used. FID compares the two sets as wholes.

The price is size. A 2048×20482048 \times 2048 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 W1W_1 as the cost of the cheapest transport plan, paying ∥x−y∥\|x - y\| per unit of mass. Paying the squared distance instead gives the 2-Wasserstein distance:

W2(P,Q)2=inf⁡γ∈Π(P,Q)E(x,y)∼γ ∥x−y∥2.W_2(P, Q)^2 = \inf_{\gamma \in \Pi(P, Q)} \mathbb E_{(x, y) \sim \gamma}\, \|x - y\|^2 .

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 x=μr+x0x = \mu_r + x_0 and y=μg+y0y = \mu_g + y_0 with centered x0x_0, y0y_0, and let C=E x0y0⊤C = \mathbb E\, x_0 y_0^\top be their cross-covariance. Expanding the square,

E ∥x−y∥2=∥μr−μg∥2+Tr⁡Σr+Tr⁡Σg−2Tr⁡C.\mathbb E\, \|x - y\|^2 = \|\mu_r - \mu_g\|^2 + \operatorname{Tr}\Sigma_r + \operatorname{Tr}\Sigma_g - 2\operatorname{Tr} C .

The cross term with the means drops out because x0−y0x_0 - y_0 has mean zero, and E x0⊤y0=Tr⁡C\mathbb E\, x_0^\top y_0 = \operatorname{Tr} C. So the best plan correlates xx and yy as strongly as the two covariances allow. The largest reachable Tr⁡C\operatorname{Tr} C is Tr⁡(ΣrΣg)1/2\operatorname{Tr}(\Sigma_r \Sigma_g)^{1/2} (the note derives it with a singular value decomposition). FID is the resulting minimum for the two fitted Gaussians:

FID=∥μr−μg∥2+Tr⁡(Σr+Σg−2 (ΣrΣg)1/2).\mathrm{FID} = \|\mu_r - \mu_g\|^2 + \operatorname{Tr}\Big(\Sigma_r + \Sigma_g - 2\,(\Sigma_r \Sigma_g)^{1/2}\Big).

The first term is the squared distance between the centers of the clouds. In the WGAN topic, shifting a distribution by aa cost ∥a∥\|a\|; with squared cost it costs ∥a∥2\|a\|^2.

The second term compares the shapes of the clouds. (ΣrΣg)1/2(\Sigma_r \Sigma_g)^{1/2} is a matrix square root, a matrix whose square is ΣrΣg\Sigma_r \Sigma_g; its trace is the sum of the square roots of the eigenvalues of ΣrΣg\Sigma_r \Sigma_g. These eigenvalues are positive, because ΣrΣg\Sigma_r \Sigma_g is similar to the symmetric positive definite matrix Σr1/2ΣgΣr1/2\Sigma_r^{1/2} \Sigma_g \Sigma_r^{1/2}. The term is never negative: it is the smallest reachable E ∥x0−y0∥2\mathbb E\, \|x_0 - y_0\|^2. It is zero only when the best plan sets x0=y0x_0 = y_0, which forces Σr=Σg\Sigma_r = \Sigma_g. 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:

FID1D=(μr−μg)2+(σr−σg)2.\mathrm{FID}_{\mathrm{1D}} = (\mu_r - \mu_g)^2 + (\sigma_r - \sigma_g)^2 .

Means are compared with means, standard deviations with standard deviations. Take real features N(0,1)\mathcal N(0, 1) and generated ones N(0.5,22)\mathcal N(0.5, 2^2). The mean term is 0.250.25, the spread term is (1−2)2=1(1 - 2)^2 = 1, and FID=1.25\mathrm{FID} = 1.25.

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 0.90.9 of its spread. Each coordinate adds (1−0.9)2=0.01(1 - 0.9)^2 = 0.01, and 2048 coordinates add 20.4820.48.

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 kk-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 00 (Jayasumana et al., 2024).

Copies are invisible. A model that returns its training images reproduces the real statistics and scores close to 00. 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 00. 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 Tr⁡Σr/Nr+Tr⁡Σg/Ng\operatorname{Tr}\Sigma_r / N_r + \operatorname{Tr}\Sigma_g / N_g. The covariance has over two million free numbers; with N≤2048N \le 2048 images its estimate is singular.

The bias shrinks roughly like 1/N1/N, and its size depends on the generator (Chong and Forsyth, 2020). So two models can swap places when NN changes. The common practice is to compare only at the same NN, usually 50 00050\,000 generated images, as in Heusel et al. (2017). That makes the numbers comparable but does not remove the bias: two models at the same NN can still be ranked by their bias rather than their quality, and Bińkowski et al. (2018) build a 2048-dimensional case where even 50 00050\,000 samples give the wrong order. Chong and Forsyth extrapolate the estimate in 1/N1/N to N→∞N \to \infty.

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 k(u,v)=(u⊤v/d+1)3k(u, v) = (u^\top v / d + 1)^3 on dd-dimensional features, KID is the squared maximum mean discrepancy

MMD2=E k(u,u′)+E k(v,v′)−2 E k(u,v),\mathrm{MMD}^2 = \mathbb E\, k(u, u') + \mathbb E\, k(v, v') - 2\, \mathbb E\, k(u, v),

where u,u′u, u' are independent real features and v,v′v, v' independent generated ones. Expanding the cube shows that it compares the moments up to order three. It is estimated by averaging kk over pairs of samples, leaving out each sample paired with itself. Then every average is unbiased, and so is the estimate, at any NN; for two identical distributions it sometimes comes out slightly negative, as an unbiased estimate of 00 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 NN, 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.

Full notes

Answers are saved on the server and tied to this browser until you sign in.