
The cosine similarity is conventionally used for evaluating the similarity of latent vectors (Salton & Buckley,
1988; Le-Khac et al., 2020; Borji, 2021) but other distance metrics could also be chosen. To avoid sensitivity
to noise in the input space, fis usually chosen to project to a latent space embedded with higher-level
semantics. It is widely believed that a pretrained image classification model can extract high-level semantics
and serves as a robust latent space for distance measurement. For example, calculation of FID involves first
passing the set of images through the Inception v3 (Szegedy et al., 2016) classification model pretrained on
ImageNet for feature extraction. A well-chosen fretrieves nearest neighbors that align well with human’s
perception. Following this definition, the distance to the nearest neighbor can serve as a quantitative measure
for sample similarity
df,XT(x) = min
x0∈XT
1−hf(x), f(x0)i
kf(x)k·kf(x0)k.
Thus, the problem of reducing memorization can be formulated as regulating the nearest neighbor distance
of generated samples, which motivates our proposed algorithm.
2.2 Quantitative evaluation of memorization
Meehan et al. (2020) proposed a non-parametric test score CTfor measuring the degree of training sample
memorization of a generative model based on sample similarity. Their key insight is that a model should
generate samples that are on average, as similar to the training data as an independently drawn test sample
from the same distribution. The model is memorizing if the generated samples are on average, more similar
to the training data than an independently drawn test sample from the same distribution.
The memorization test is based on the Mann-Whitney U test, a non-parametric statistical test for testing
the ordinal relationship with the null hypothesis that the given two sets of samples are from the same
distribution. In this case, the two sets of samples are the nearest neighbor distances (with respect to the
training data) of a generated set and a reference testing set. The more severe the memorization, the more
negative the U statistics, and vice versa. Additionally, to better detect local memorization, the input domain
can be divided into subspaces and the test score is aggregated over memorization tests performed on each
of the subspaces. In this paper, we adopt the definition of memorization as characterized by the CTvalues.
2.3 Generation quality and memorization
Figure 1: Nearest neighbor distance distribution of the
reference testing set (CIFAR10.1) versus BigGAN.
Good generation quality and reduced memorization
can coexist. In the ideal case, if the generator per-
fectly fits the underlying data distribution, then the
generated samples have perfect quality and are in no
way more similar to the training data than another
independent sample from the distribution. However,
GAN models are imperfect. Figure 1 shows the near-
est neighbor distance distribution (approximated by
2K samples) of a generated set from BigGAN and
a reference testing set (CIFAR10.1). If the model
successfully learned the data distribution, the ex-
pectations of the two nearest neighbor distributions
should be identical. However, samples generated
from BigGAN (orange line) are in fact closer to the
training data than samples from the reference test-
ing set (highlighted in orange) which indicates the
memorization phenomenon.
In general, it is true that generated samples with
smaller nearest neighbor distances are associated
with better quality. Smaller distances imply being closer to the training distribution. Figure 2 visual-
izes a subset of 5k samples from a BigGAN trained on CIFAR10. The images are sorted by their nearest
neighbor distance. From top to bottom, each row shows 10 images from the 20%, 40%, 60%, 80%, and 100%
3