Abstract
Detecting overfitting in generative models is an important challenge in machine learning. In this work, we formalize a form of overfitting that we call data-copying – where the generative model simply memorizes and regurgitates training data. We introduce a novel, non-parametric three-sample hypothesis test that compares the distances of generated samples and held-out test samples to the training set. This test accurately quantifies data-copying across various models and datasets, addressing a critical blind spot in existing evaluation metrics.
Introduction
Evaluating generative models, such as GANs and VAEs, is notoriously difficult. Modern architectures often lack tractable likelihoods, forcing researchers to rely on sample-based metrics like Fréchet Inception Distance (FID) or Precision & Recall. While these metrics are effective at detecting "mode collapse" (lack of diversity), they are largely blind to data-copying. A model that memorizes the training set can achieve excellent scores on traditional metrics while failing to learn the underlying distribution. We propose a robust statistical framework to detect and quantify this phenomenon.
Methodology: The Three-Sample Test
The core of our approach is a three-sample hypothesis test designed to determine if a model is producing samples that are "too close" to the training data.
The Three-Sample Framework
We consider three sets of samples:
- Training set ($T$): The data used to train the model.
- Test set ($P_n$): A held-out set of real samples from the same distribution.
- Generated set ($Q_m$): Samples produced by the generative model.
The intuition is that if a model is data-copying, its generated samples ($Q_m$) will be closer to the training set ($T$) than the independent test samples ($P_n$) are. We measure the distance from each sample in $Q_m$ and $P_n$ to its nearest neighbor in $T$. A Mann-Whitney U test is then used to compare these distance distributions.
Local Heterogeneity and the $C_T$ Statistic
Models often exhibit local overfitting—memorizing one class of data while underfitting another. To account for this, we partition the data space into cells (e.g., via k-means). We perform the U-test within each cell and aggregate the results into a summary z-score, $C_T$.
- $C_T \ll 0$: Indicates significant data-copying.
- $C_T \approx 0$: Indicates the model matches the target distribution's proximity to the training set.
- $C_T \gg 0$: Indicates underfitting (samples are too far from training data).
Experimental Setup
We validated our test on three distinct datasets: the 2D 'Moons' toy dataset, MNIST handwritten digits, and high-resolution ImageNet12 classes. For image data, we utilize latent space embeddings (e.g., from a custom autoencoder or pre-trained InceptionV3) to ensure distance calculations are perceptually meaningful.
Key Insights
Failure of Existing Metrics
Standard metrics often reward memorization. In experiments with Kernel Density Estimators (KDE), we found that as the model was forced to memorize the training data (by decreasing the bandwidth $\sigma$), metrics like FID and Binning-Based Evaluation failed to signal a problem. As shown in the figure below, the binning-based metric remains low during overfitting (low $\sigma$) and only rises when the model begins to underfit.
The Quality-Copying Trade-off
In GANs, reducing the "truncation threshold" is a common technique to improve visual quality. Our test reveals that this often comes at the cost of data-copying. As the threshold decreases, the $C_T$ statistic drops sharply, indicating that the "higher quality" images are actually just samples suspiciously close to the training set.
Results
- VAE Overfitting: On MNIST, the $C_T$ statistic accurately tracked the overfitting of VAEs as model complexity increased. The point where $C_T$ crossed zero aligned perfectly with the peak of the held-out validation ELBO.
- BigGAN Analysis: For state-of-the-art models like BigGAN, our test identified that low truncation thresholds lead to excessive probability mass being placed on training samples, a fact hidden by standard FID scores.
Conclusion
The three-sample hypothesis test provides a necessary diagnostic tool for the generative modeling community. By explicitly detecting data-copying, it allows researchers to distinguish between true generalization and sophisticated memorization. Future work will focus on theoretical convergence guarantees and the impact of different embedding spaces on test sensitivity.
Summary updated