SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Feature Likelihood Divergence: Evaluating the Generalization of Generative Models Using Samples
Marco Jiralerspong*  
Université de Montréal and Mila
Avishek (Joey) Bose  
McGill University and Mila
Ian Gemp  
Google Deepmind
Chongli Qin Google Deepmind
Yoram Bachrach  
Google Deepmind
Gauthier Gidel†  
Université de Montréal and Mila
The past few years have seen impressive progress in the development of deep generative models capable of producing high-dimensional, complex, and photo-realistic data. However, current methods for evaluating such models remain incomplete: standard likelihood-based metrics do not always apply and rarely correlate with perceptual fidelity, while sample-based metrics, such as FID, are insensitive to overfitting, i.e., inability to generalize beyond the training set. To address these limitations, we propose a new metric called the Feature Likelihood Divergence (FLD), a parametric sample-based metric that uses density estimation to provide a comprehensive trichotomic evaluation accounting for novelty (i.e., different from the training samples), fidelity, and diversity of generated samples. We empirically demonstrate the ability of FLD to identify overfitting problem cases, even when previously proposed metrics fail. We also extensively evaluate FLD on various image datasets and model classes, demonstrating its ability to match intuitions of previous metrics like FID while offering a more comprehensive evaluation of generative models. Code is available at https://github.com/marcojira/fld.
Generative modeling is one of the fastest-growing areas of deep learning, with success stories spanning the artificial intelligence spectrum [Karras et al., 2020, Brown et al., 2020, Wu et al., 2021, Rombach et al., 2022]. Despite the growth of applications—and unlike supervised or reinforcement learning—there is a lack of a clear consensus on an evaluation protocol in high-dimensional data regimes in which these models excel. In particular, the standard metric of evaluating log-likelihood of held-out test data [Bishop and Nasrabadi, 2006, Goodfellow et al., 2016, Murphy, 2022] fails to provide a meaningful evaluation signal due to its large variability between repetitions [Nowozin et al., 2016] and lack of direct correlation with sample fidelity [Theis et al., 2015].
Departing from pure likelihood-based evaluation, sample-based metrics offer appealing benefits such as being able to evaluate any generative model family via their generated samples. Furthermore, sample-based metrics such as Inception score (IS) [Salimans et al., 2016], Fréchet Inception distance (FID) [Heusel et al., 2017], precision, and recall [Lucic et al., 2018, Sajjadi et al., 2018] have been shown to correlate with sample quality, i.e. the perceptual visual quality of a generated sample, and the perceptual sample diversity. Despite being the current defacto gold standard, sample-based
*e-mail correspondence to marco.jiralerspong@mila.quebec
† Canada Cifar AI Chair
$^{\ddagger}$ Our metric (FLD) was named Feature Likelihood Score (FLS) in the previous versions of this paper.
Figure 1: The generative model evaluation "trichotomy": fidelity, diversity and novelty. Each metric maps to a color delimiting its criteria for evaluation.
Figure 2: Test FID/FLD of various models on CIFAR10. FID values are higher than usual as we use the DINOv2 feature space with the test set as reference (10k samples) instead of the usual 50k.
metrics miss important facets of evaluation [Xu et al., 2018, Esteban et al., 2017, Meehan et al., 2020]. For example, on CIFAR10, the current standard FID computation uses  $50\mathrm{k}$  generated samples and  $50\mathrm{k}$  training samples from the dataset, a practice that does not take into account overfitting. Consider the worst-case scenario of a model called copycat which simply outputs copies of the training samples. Using the standard evaluation protocol, such a model would obtain a  $FID$  of 0 (as we compare distances of two identical Gaussians)—a perfect score for a useless model. Instead, we could try looking at the FID of the copycat relative to the test set. While this improves the situation somewhat (see Fig. 2), copycat still obtains better than SOTA test FID, demonstrating that aiming for the lowest FID is highly vulnerable to overfitting.
While old generative models struggled to produce good quality samples, recent models have demonstrated the ability to memorize [Somepalli et al., 2022] and overfit [Yazici et al., 2020]. With the widespread adoption of deep generative models in high-stakes and industrial production environments, important concerns regarding data privacy [Carlini et al., 2023, Arora et al., 2018, Hitaj et al., 2017] should be raised. For instance, in safety-critical application domains such as precision medicine, data leakage in the form of memorization is unacceptable and severely limits the adoption of generative models—a few of which have been empirically shown to be guilty of "digital forgery" [Somepalli et al., 2022]. These concerns highlight the limitations with current evaluation metrics:
There are currently no sample-based evaluation metrics accounting for the trichotomy between sample fidelity, diversity, and novelty (Figure 1).
We believe this trichotomy encompasses what is required for a generative model to have the desired generalization properties, i.e., a "good" generative model should generate samples that are diverse and perceptually indistinguishable from the training data distribution, but at the same time, different from that training data. In other words, the more generated data looks like unseen test samples, the better. Additionally, by assessing the novelty of generated samples in relation to the training set, we can better identify potential privacy and copyright risks.
Main Contribution. We propose the feature likelihood divergence (FLD): a novel sample-based metric that captures sample fidelity, diversity, and novelty. FLD enjoys the same scalability as popular sample-based metrics such as FID and IS but crucially also assesses sample novelty, overfitting, and memorization. Evaluation using FLD has many consequential benefits:
1. Explainability: Samples that contribute the most (and the least) to the performance are identified.
2. Diagnosing Overfitting: As overfitting begins (i.e., copying of the training set) FLD identifies the copies and reports an inferior value despite no drop in sample fidelity and diversity.
3. Holistic Evaluation: FLD simultaneously is the only metric proposed in the literature that simultaneously evaluates the fidelity, diversity, and novelty of the samples (Fig. 1).
4. Universal Applicability: FLD applies to all generative models, including VAEs, Normalizing Flows, GANs, and Diffusion models with minimal overhead as it is computed only using samples.
5. Flexibility: Because of its connection with likelihood, FLD can be naturally extended to conditional and multi-modal generative modeling.
Intuitively, FLD achieves these goals by first mapping samples to a perceptually meaningful feature space such as a pre-trained Inception-v3 [Szegedy et al., 2016] or DINOv2 [Oquab et al., 2023]. Then, FLD is derived from the likelihood evaluation protocol that assesses the generalization performance of generative models in a similar manner to supervised learning setups. As most models lack explicit densities, we model the density of the generative model in our chosen feature space by using a mixture of isotropic Gaussians (MoG), whose means are the mapped features of the generated samples. We then fit the variances of the Gaussians to the train set in such a way that memorized samples obtain vanishingly small variances and thus worsen the density estimation of the MoG. Finally, we use the MoG and estimate the perceptual likelihood of some held-out test set.
Given a training dataset  $\mathcal{D}_{\mathrm{train}} = \{\mathbf{x}_i\}_{i=1}^n$  drawn from a distribution  $p_{\mathrm{data}}$ , one of the key objectives of generative modeling is to train a parametric model  $g$  that is able to generate novel synthetic yet high-quality samples—i.e., the distribution  $p_g$  induced by the generator is close to  $p_{\mathrm{data}}$ .<sup>3</sup>
Likelihood Evaluation. The most common metric, and perhaps most natural, is the negative log-likelihood (NLL) of the test set, whenever it is easily computable. While appealing theoretically, generative models typically do not provide a density (e.g. GANs) or it is only possible to compute a lower bound of the test NLL (e.g. VAEs, continuous diffusion models, etc.) [Burda et al., 2015, Song et al., 2021, Huang et al., 2021]. Even when possible, NLL-based evaluation suffers from a variety of pitfalls in high dimensions [Theis et al., 2015, Nowozin et al., 2016] and may often not correlate with higher sample quality [Nalisnick et al., 2018, Le Lan and Dinh, 2021]. Indeed many practitioners have empirically witnessed phenomena such as mode-dropping, mode-collapse, and overfitting [Yazici et al., 2020], all of which are not easily captured simply through the NLL.
Sample-based Metrics. As all deep generative models are capable of producing samples, an effective way to evaluate these models is via their samples. Such a strategy has the benefit of bypassing the need to compute the exact model density of a sample point—allowing for a unified evaluation setting. More precisely, given  $\mathcal{D}_{\mathrm{gen}} = \{\mathbf{x}^{\mathrm{gen}}\}_{i=1}^{m}$  generated samples, where each  $\mathbf{x}^{\mathrm{gen}} \sim p_g$  and  $\mathcal{D}_{\mathrm{test}} = \{\mathbf{x}^{\mathrm{test}}\}_{i=1}^{n}$  drawn from  $p_{\mathrm{data}}$ , the goal is to evaluate how "good" the generated samples are with respect to the real data distribution. Historically, sample-based metrics for evaluating deep generative models have been based on two ideas: 1. using an Inception network [Szegedy et al., 2016] backbone  $\varphi$  as a feature extractor to 2. compute a notion of distance (or similarity) between the generated and the real distribution. The Inception Score (IS) and the Fréchet Inception Distance (FID) are the two most popular examples and can be computed as follows:
$$
\text {I S :} e ^ {\frac {1}{m} \sum_ {i = 1} ^ {m} \mathrm {K L} (p _ {\varphi} (y | \mathbf {x} _ {i} ^ {\mathrm {g e n}}) | | p _ {d} (y))}, \quad \text {F I D :} \| \mu_ {g} - \mu_ {p} \| ^ {2} + \operatorname {T r} (\Sigma_ {g} + \Sigma_ {p} - 2 (\Sigma_ {g} \Sigma_ {p}) ^ {1 / 2})
$$
where  $p_{\varphi}(y|x)$  is the probability of each class given by the Inception network  $\varphi$ ,  $p_d(y)$  is the ratio of each class in the real data,  $\mu_g := \frac{1}{m} \sum_{i=1}^{m} \varphi(\mathbf{x}_i^{\text{gen}})$ ,  $\mu_p := \frac{1}{n} \sum_{i=1}^{n} \varphi(\mathbf{x}_i^{\text{test}})$  are the empirical means of each distribution, and  $\Sigma_g := \frac{1}{m} \sum_{i=1}^{m} (\mathbf{x}_i^{\text{gen}} - \mu_g)(\mathbf{x}_i^{\text{gen}} - \mu_g)^{\top}$ ,  $\Sigma_p := \frac{1}{n} \sum_{i=1}^{n} (\mathbf{x}_i^{\text{test}} - \mu_p)(\mathbf{x}_i^{\text{test}} - \mu_p)^{\top}$  are the empirical covariances.
The popularity of IS and FID as metrics for generative models is motivated by their correlation with perceptual quality, diversity, and ease of use. More recently, other metrics such as KID [Binkowski et al., 2018] (an unbiased version of FID) and precision/recall (which disentangles sample quality and distribution coverage) [Sajjadi et al., 2018] have added nuance to generative model evaluation.
Overfitting Evaluation. Several approaches seek to provide metrics to detect overfitting and can be categorized based on whether one can extract an exact likelihood [van den Burg and Williams, 2021] or a lower bound to it via annealed importance sampling [Wu et al., 2016]. For GANs, popular approaches include training an additional discriminator in a Wasserstein GAN [Adlam et al., 2019] and adding a memorization score to the FID [Bai et al., 2021]. Alternate approaches include finding real data samples that are closest to generated samples via membership attacks [Liu et al., 2018, Webster et al., 2019]. Non-parametric tests have also been employed to detect memorization or exact data copying in generative models [Xu et al., 2018, Esteban et al., 2017, Meehan et al., 2020]. Parametric approaches to detect data copying have also been explored such as using neural network divergences [Gulrajani et al., 2020] or using latent recovery [Webster et al., 2019]. Finally, the  $C_T$
3By close we mean either a divergence between distributions (e.g. KL, JSD) or a distance like Wasserstein.
Figure 3: Steps involved in our overfit mixture of Gaussians illustrated on a 2D example
[Meehan et al., 2020] test statistic and Alaa et al. [2022] proposes a multi-faceted metric with a binary sample-wise test to determine whether a sample is authentic (i.e., overfit).
3 Feature Likelihood Divergence
We now introduce our Feature Likelihood Score (FLD) which is predicated on the belief that a proper evaluation measure for generative models should go beyond sample quality and also inform practitioners of the generalization capabilities of their trained models. While previous sample-based methods have foregone density estimation in favor of computing distances between sample statistics, we seek to bring back a likelihood-based approach to evaluating generative models. To do so, we first propose our method for fitting a mixture of Gaussians (MoGs) to estimate the perceptual density of high-dimensional samples in a way that accounts for overfitting. Specifically, our method aims at attributing 1) a good NLL to high-quality, non-overfit images and 2) a poor NLL in cases of overfitting.
Intuitively, we say a generative model is overfitting if on average the distribution of generated samples is closer to the training set than the test set in feature space. We seek to characterize this exact behavior with FLD by a MoG where the variance parameter  $\sigma^2$  of each Gaussian approaches zero around generated samples that are responsible for overfitting. In section 3.1 we deepen this intuition by outlining how the MoG used in FLD can be tuned to assess the perceptual likelihood of samples while punishing memorized samples, before giving a precise definition for memorization and overfitting under FLD in section 3.2.
3.1 Overfitting Mixtures of Gaussians
Our method consists of a simple sample-based density estimator amenable to a variety of data domains inspired by a traditional mixture of Gaussians (MoG) density estimator with a few key distinctions. Figure 3 summarizes the 4 key steps in computing FLD using our MoG density estimator (also detailed in Algorithm 1 in Appendix §D.1) which we now describe below. While it is indeed possible to train any other density model, a MoG offers a favorable tradeoff in being simple to use—while still being a universal density estimator [Nguyen et al., 2020]—and enjoying efficient scalability to large datasets.
Step 1: Map to the feature space. The first change we make is to use some map  $\varphi$  to map inputs to some perceptually meaningful feature space. Natural choices for this include the representation space of Inception-v3 and DINOv2. While still high-dimensional, we ensure that a larger proportion of dimensions are useful and that the resulting  $\ell_2$  distances between images are more meaningful.
Step 2: Model the density using a MoG. As in kernel density estimation (KDE), to estimate a density from some set of points  $\mathcal{D}_{\mathrm{gen}} = \{\mathbf{x}_j^{\mathrm{gen}}\}_{j=1}^m$  we center an isotropic Gaussian around each point—i.e., the mean of the Gaussian is the coordinates of the point. This means that  $j$ -th data point has a Gaussian  $\mathcal{N}(\varphi(\mathbf{x}_j^{\mathrm{gen}}), \sigma_j^2 I_d)$ . Then, to compute the likelihood of a new point  $\mathbf{x}$ , we simply calculate the mean likelihood assigned to that point by all Gaussians in the mixture:
$$
p _ {\sigma} (\mathbf {x} \mid \mathcal {D} _ {\text {g e n}}) := \frac {1}{m} \sum_ {j = 1} ^ {m} \mathcal {N} (\varphi (\mathbf {x}) \mid \varphi \left(\mathbf {x} _ {j} ^ {\text {g e n}}\right), \sigma_ {j} ^ {2} I _ {d}) = \frac {1}{m} \sum_ {j = 1} ^ {m} \frac {1}{(\sqrt {2 \pi} \sigma_ {j}) ^ {d}} \exp \left(\frac {- | | \varphi \left(\mathbf {x} _ {j} ^ {\text {g e n}}\right) - \varphi (\mathbf {x}) | | ^ {2}}{2 \sigma_ {j} ^ {2}}\right) \tag {1}
$$
with the convention that  $\mathcal{N}(\varphi(\mathbf{x})|\varphi(\mathbf{x}^{\mathrm{gen}}), 0_d)$  is a dirac at  $\varphi(\mathbf{x}^{\mathrm{gen}})$ . Henceforth, we denote this MoG estimator which has fixed centers initialized to a dataset (e.g. train set, generated set) as  $\mathcal{N}(\varphi(\mathcal{D}); \Sigma)$ , where  $\Sigma$  is a diagonal matrix of bandwidths parameters—i.e.  $\sigma^2 I$ , where  $\sigma^2$  is a vector.
Step 3: Use the train set to select  $\sigma_j^2$ . An important question in kernel density estimation is selecting an appropriate bandwidth  $\sigma_j^2$ . Overwhelmingly, a single bandwidth is selected which can either be derived statistically or by minimizing some loss through cross validation [Murphy, 2012]. We depart from this single bandwidth philosophy in favor of separate  $\sigma_j^2$  values for each Gaussian. To select  $\sigma_j^2$ , instead of performing standard cross-validation on samples from  $p_g$ , we fit the bandwidths using
a subset of training examples  $\{\varphi (\mathbf{x}_i^{\mathrm{train}})\}_{i = 1}^n$  by minimizing their negative log-likelihood (NLL). Specifically, we solve the following optimization problem:
$$
\hat {\sigma} ^ {2} \in \arg \max _ {\sigma^ {2}} \frac {1}{n} \sum_ {i = 1} ^ {n} \log \left(\frac {1}{m} \sum_ {j = 1} ^ {m} \frac {1}{(\sqrt {2 \pi} \sigma_ {j}) ^ {d}} \exp \left(\frac {- | | \varphi (\mathbf {x} _ {j} ^ {\mathrm {g e n}}) - \varphi (\mathbf {x} _ {i} ^ {\mathrm {t r a i n}}) | | ^ {2}}{2 \sigma_ {j} ^ {2}}\right) + \mathcal {L} _ {i}\right) \tag {2}
$$
where  $\mathcal{L}_i$  is a base likelihood given to each sample (see Appendix §D for details). In particular, by centering each Gaussian on each  $\mathbf{x}_j^{\mathrm{gen}}\in \mathcal{D}_{\mathrm{gen}}$  and fitting each  $\sigma_j^2$  to the train set, we aim to have memorized samples obtain an overly small  $\sigma_j^2$ , worsening the quality of the MoG estimator (and thus penalizing memorization). The following proposition (proof in §F) formalizes this intuition.
Proposition 1. Let  $D_{ij} \coloneqq ||\varphi(\mathbf{x}_j^{gen}) - \varphi(\mathbf{x}_i^{train})||^2$  be the distance between a generated sample and a train sample. Assume  $\forall i, j: D_{ij} \leq \hat{D}$  with  $\delta_j \coloneqq \min_i D_{ij}$ . Then, for any  $l \in \{1, \dots, m\}$ , we have that  $\hat{\sigma}_l = O(\delta_l)$  where  $\hat{\sigma}^2$  is a solution of Eq. 2.
Proposition 1 implies that each element of the training set that has been memorized induces a Dirac in the MoG density Eq. 1. Thus, one can identify copies of training samples with the learned density. More generally, if one of the generated samples is unreasonably close to a training sample, its associated  $\sigma^2$  will be very small as this maximizes the likelihood of the training sample. We illustrate this phenomenon with the Two-Moons dataset [Pedregosa et al., 2011] in Figure 4. Note that since this dataset is low-dimensional, we do not need to use a feature extractor (Step 1). In Figure 4 we can see that the more approximate copies of the training set appear in the generated set, the more the estimated density (using Eq. 2) contains high values around approximate copies of the training set. As such, overfitted generated samples yield an overfitted MoG that does not model the distribution of real data  $p_{\mathrm{data}}$  and will yield poor (i.e., low) log-likelihood on the test set  $\mathcal{D}_{\mathrm{test}}$ .
Figure 4: Estimated density (in purple) of the generated distribution using an MoG centered at the generated samples  $\mathbf{x}_i^{\mathrm{gen}}$  (in blue) Eq. 1. The selection of  $\sigma_i^2$  is done via Eq. 2. The training points  $\mathbf{x}_i^{\mathrm{train}} \sim p_d$ , sampled from the two-moons dataset, are represented in orange. The generated points correspond to  $k$  approximates copies of the training set  $\mathbf{x}_i^{\mathrm{gen}} = \mathbf{x}_i^{\mathrm{train}} + \mathcal{N}(0, 10^{-4})$ ,  $i = 1, \dots, k$  and  $200 - k$  independent samples from the data distribution  $\mathbf{x}_i^{\mathrm{gen}} \sim p_d$ ,  $i = k + 1, \dots, 200$ . The dark areas correspond to high-density values.
Step 4: Evaluate MoG density. A foundational concept used by FLD is to evaluate the perceptual negative log-likelihood of a held-out test set using an MoG density estimator. To quantitatively evaluate the density obtained in Step 3, we evaluate the negative log-likelihood of  $\mathcal{D}_{\mathrm{test}}$  under  $p_{\hat{\sigma}}(\mathbf{x})$ . As demonstrated in Figure 4, in settings with  $k > 0$ , the generated samples are too close to the training set, meaning that all test samples will have a high negative log-likelihood (as they are far from the center of Gaussians with low variances). Evaluation of the test set provides a succinct way of measuring the generalization performance of our generative model, which is a key aspect that is lost in metrics such as IS and FID. Our final FLD score is thus given by the following expression:
$$
\operatorname {F L D} \left(\mathcal {D} _ {\text {t e s t}}, \mathcal {D} _ {\text {g e n}}\right) := - \frac {1 0 0}{d} \log p _ {\hat {\sigma}} \left(\mathcal {D} _ {\text {t e s t}} \mid \mathcal {D} _ {\text {g e n}}\right) - C, \tag {3}
$$
where  $d$  is the dimension of the feature space  $\varphi$  and is equivalent to looking at the  $d^{th}$  root of the likelihood, and  $C$  is a dataset dependant constant. As a result of this adjustment by a constant, FLD is essentially estimating the forward Kullback-Leibler (KL) divergence (up to a constant factor) between the learned MoG distributions of the true data and the generated data. Higher FLD score values are indicative of problems in some of the three areas evaluated by FLD. Poor sample fidelity
<sup>4</sup>We set  $C$  for the FLD to be zero with an ideal generator (i.e. a generator that could sample images from the true data distribution). In practice we can estimate such a  $C$  by splitting the train set in 2, one part to represent the perfect  $\mathcal{D}_{\mathrm{gen}}$  and the other to compute  $\hat{\sigma}$ . Note that  $C$  does not change the relative score between models.
leads to Gaussian centers that are far from the test set and thus a higher NLL. Similarly, a failure to sufficiently cover the data manifold will lead to some test samples yielding very high NLL. Finally, overfitting to the training set will yield a MoG density estimator that overfits and yield a poor NLL value on the test set.
Computational Complexity of FLD. To quantify the computational complexity of FLD we plot, in Figure 12 in §A.2, the computation time of various metrics with the number of samples. As depicted, we observe a linear scaling in the number of train samples for FLD which is in line with the computational cost of popular metrics like FID. Finally, the cost of computing FLD—and other metrics—is dwarfed by the cost of generating samples and then mapping them to an appropriate feature space which is a one-time cost and can be done prior to any metric computation.
3.2 Detecting Memorization and Overfitting
Memorization. One of the key advantages of FLD over other metrics like FID is that it can be used to precisely characterize memorization at the sample level. Intuitively, memorization occurs when a generated sample  $\mathbf{x}_j^{\mathrm{gen}}$  is an approximate copy of a training sample  $\mathbf{x}_i^{\mathrm{train}}$ . By Proposition 1, such a phenomenon encourages the optimization of Eq. 2 to select a  $\hat{\sigma}_j^2 \ll 1$  to achieve a high training NLL. As a result, such samples will assign a disproportionately high likelihood to that  $\mathbf{x}_i^{\mathrm{train}}$ . To quantify this phenomenon, we compute the train likelihood assigned by each fitted Gaussian.
Definition 3.1. Let  $\delta >0$ . The sample  $x_{j}^{\mathrm{gen}}$  is said to be  $\delta$ -memorized if