Paper: Why are Modern GANs Poor Density Models? (ICLR-2024)

Reviewer comment (Experiments):
The explanation of the z-reconstruction error is not entirely clear. Based on the reviewer’s intuition, it seems that the latent is optimized to maximize the likelihood of reconstructing the image, which is equivalent to minimizing the sample's reconstruction error. If this understanding is correct, there appear to be concerns related to experimental design and the claims made when using the z-reconstruction method as a proxy for validating the model's density, particularly when working with limited data. In Figure 1, the authors demonstrate that the GAN can reconstruct the generated images better than the training images, which is predictable because the GAN was optimized during training to generate these specific images, making them easier to reconstruct and resulting in lower error. Considering a bad GAN model that collapses to a specific mode of data distribution, such a GAN excels at reconstructing these samples but may struggle with reconstructing images outside of this mode. When using only a limited dataset, it is possible that the examples representing the mode the GAN learned are not included. A comprehensive investigation requires access to the full dataset to ensure robust support for the findings. The reviewer requests a plot of the full dataset. This also relates to Figure 2, as there might be training examples that the GAN could collapse into, and if these examples are not utilized, the complete representation of the training distribution may be lacking.

Author response:
We disagree with your interpretation of figure 1. You write that “The results are predictable because the GAN was optimized during training to generate these specific images,” but the GANs were optimized to generate TRAINING images, not GENERATED images, and figure 1 shows that training  images are not reconstructed well. Regarding the hypothesis that the GANS might be reconstructing well a subset of the training images, please see figure 2 which shows the histogram of the reconstruction error. You can see that for StyleGAN-XL on CIFAR10 almost all training images have an L2 reconstruction error that is much larger than that of the reconstruction error for the generated images (note the log scale on the x-axis).

Reviewer comment (Evaluation):
The reconstructions of SVHN and flat images in Figure 1 are equally poor when compared to the training examples. While GANs manage to capture the global color appearance and shape, they struggle with preserving finer details of the images. Even for flat images, patterns from the training distributions can still be discerned, indicating they are not entirely flat. Only the reconstructions of the generated images from the model appear to be good, largely for reasons mentioned earlier. Therefore, it may not be sufficient to assert that the model "can copy images completely outside the original training distribution," as the reconstruction behavior seems consistent across most images, and this claim should be approached with caution.

Author response:
We agree with the reviewer that such claims should be approached with caution. However, in this statement was made due to the results shown in figure 7, in which flat and SVHN images clearly have (in general) a much lower reconstruction error (please note that the errors are in log scale!). Of course, we do not want to mislead readers and if the reviewer still feels that this is inappropriate, we will modify the statement in the introduction.

Reviewer comment (Reproducibility):
One crucial aspect missing from the authors’ discussion is the value of the optimized z. GANs are optimized with a specific latent distribution, such as a Gaussian within a defined range, and may behave differently when confronted with latent variables outside this distribution. It would be beneficial if the authors could provide more information about the latent distribution used for generating images in the investigated GAN models, as well as compare the optimized z values for SVHN and flat images to those optimized for the generated samples and training images. This comparison is only valid if the optimized z values fall within the latent distribution the GAN was originally trained with. The choice of optimized z values could significantly impact all results in the paper. If the optimized z values are far outside the trained latent distribution, this could call into question the validity of the findings. A similar concern applies to Figure 5. If the optimized z values are outside the latent distribution, it may lead to KL divergence values remaining relatively constant, dominated by the reconstruction term, which tends to be better optimized.

Author response:
We agree that the norm of the latent code influences the likelihood. Note however, that  the first layer of many StyleGANs (such as StyleGAN-XL and StyleGAN2 which we used) is an InstanceNormalization layer which normalizes the latent code to have a norm of 1 and our z-reconstruction also satisfies the same constraint. In other words, for these StyleGAN models all the latent codes that are found for out of distribution images are of the same norm as the ones within distribution. For the other models, we did not see a significant difference between the norms of latent codes for in-distribution vs out-of-distribution. We agree that these results should be included in a future version.

Reviewer comment (Theory):
Some of the assumptions and motivational arguments could benefit from more explanation. "The GAN is able to generate realistic samples but is unable to reconstruct training images when only z is optimized." There should be some justification here explaining why this is possible even though the optimization problem defined in eq. (7) is np-hard [Inverting Deep Generative Models].

Author response:
We thank the reviewer for their comments and suggestions.

As we understand, the major concerns of the reviewer are with how well GANs capture densities and the definition of the z-reconstruction. For the first of these, please see the general comment we made to all reviewers. Briefly, it has previously been shown theoretically that the optimum of a GAN is the true training distribution.

As the reviewer mentioned, fully solving the z-reconstruction optimization problem is NP-hard. However, we use methods common to many other studies, in particular gradient descent with multiple random restarts. As is evident from figure 1 and 8, this method DOES give almost perfect reconstructions for images generated by the GAN. This means that despite the worst-case hardness results, it is possible to approximately solve the z-reconstruction problem for many cases. On the other hand, using exactly the same method, training/test reconstructions are visibly very different from the original images. Figure 2 demonstrates this quantitatively - the errors of the optimization process are much larger for training images than for images generated by the GAN itself. Please let us know if this does not resolve your issues with the z-reconstruction.

Reviewer comment (Evaluation):
Analysis of the z-reconstruction error term: This error will exist because a k-dimensional vector cannot represent all of $R^{n}$, this has been extensively studied in the field of GANprior [Compressed Sensing using Generative Models]. The density truly lies only in the range of $G(z)$, but since noise was added to the manifold to have a well-defined density over $R^{n}$, it is unclear if the poor reconstruction error and likelihood are dominated by the noise added to the manifold or the n-k dimensions of the manifold z cannot represent. A noise-to-signal ratio metric would mitigate this issue.

Author response:
Answering the reviewer’s questions:
1) The values for the noise that we used and their SNRs can be seen in the following table, which will be added to the appendix:

| GAN |  Dataset |  Value of $\\gamma^{-1}$ | SNR |
| ---- | ------------ | ----------------------- | --- |
| BigGAN |  CIFAR10 |  0.0062 | 30.5 |  
| ICRGAN | CIFAR10 | 0.0076 | 24.9 |
| ReACGAN | CIFAR10 | 0.0071 | 26.4 | 
| StyleGAN-XL | CIFAR10 | 0.015 | 14 |
| BigGAN | ImageNet10 |  0.012 | 12.3 |
| ReACGAN | ImageNet10 | 0.015 | 9.6 |
| StyleGAN-XL | ImageNet10 | 0.016 | 9.1 |
| StyleGAN2-ADA | AFHQCat | 0.022 | 10.2 |
| StyleGAN2-ADA | AFHQDog | 0.021 | 8.7 |

Reviewer comment (Experiments):
Could the authors provide metrics for noise to signal ratios of the observed model $x=G_{\theta}(z) + \eta$ for training and test sets?

Author response:
Answering the reviewer’s questions:
1) The values for the noise that we used and their SNRs can be seen in the following table, which will be added to the appendix:

| GAN |  Dataset |  Value of $\\gamma^{-1}$ | SNR |
| ---- | ------------ | ----------------------- | --- |
| BigGAN |  CIFAR10 |  0.0062 | 30.5 |  
| ICRGAN | CIFAR10 | 0.0076 | 24.9 |
| ReACGAN | CIFAR10 | 0.0071 | 26.4 | 
| StyleGAN-XL | CIFAR10 | 0.015 | 14 |
| BigGAN | ImageNet10 |  0.012 | 12.3 |
| ReACGAN | ImageNet10 | 0.015 | 9.6 |
| StyleGAN-XL | ImageNet10 | 0.016 | 9.1 |
| StyleGAN2-ADA | AFHQCat | 0.022 | 10.2 |
| StyleGAN2-ADA | AFHQDog | 0.021 | 8.7 |

Reviewer comment (Theory):
Could the authors please justify why this is a reasonable assumption? "The GAN is able to generate realistic samples but is unable to reconstruct training images when only z is optimized," even though the defined optimization problem is np-hard.

Author response:
We thank the reviewer for their comments and suggestions.

As we understand, the major concerns of the reviewer are with how well GANs capture densities and the definition of the z-reconstruction. For the first of these, please see the general comment we made to all reviewers. Briefly, it has previously been shown theoretically that the optimum of a GAN is the true training distribution.

As the reviewer mentioned, fully solving the z-reconstruction optimization problem is NP-hard. However, we use methods common to many other studies, in particular gradient descent with multiple random restarts. As is evident from figure 1 and 8, this method DOES give almost perfect reconstructions for images generated by the GAN. This means that despite the worst-case hardness results, it is possible to approximately solve the z-reconstruction problem for many cases. On the other hand, using exactly the same method, training/test reconstructions are visibly very different from the original images. Figure 2 demonstrates this quantitatively - the errors of the optimization process are much larger for training images than for images generated by the GAN itself. Please let us know if this does not resolve your issues with the z-reconstruction.

Reviewer comment (Theory):
Could the authors provide a justification on why we should expect GANs to be good at estimating density when they are not trained specifically for such a task?

Author response:
We thank the reviewer for their comments and suggestions.

As we understand, the major concerns of the reviewer are with how well GANs capture densities and the definition of the z-reconstruction. For the first of these, please see the general comment we made to all reviewers. Briefly, it has previously been shown theoretically that the optimum of a GAN is the true training distribution.

Reviewer comment (Reproducibility):
Could the authors please describe the procedure for how the flat images are created? Also, what is the definition of flat? Is this a reference to the manifold of the image?

Author response:
Answering the reviewer’s questions:
4) As written in section 3, flat images are just images of a single color. To generate these images, we sample 3 values from a uniform distribution in the range (0, 1), all pixels in the red channel of the image are equal to the first value, pixels in the green to the second and the blue channel is equal to the last. Examples of these images can be seen in figures 1 and 8, always at the right-most side of the figure.

Reviewer comment (Evaluation):
The authors report that the GANs should be, based on their results, bad at outlier detection and that they do not memorize training samples. However, prior works on GANs have reported the exact opposite results in both these cases. There is large body of literature on GANs being used for anomaly detection [3] and there is work demonstrating both theoretically [4] and empirically [5] that GANs tend to memorize training samples. I am thinking this might be because the estimated log likelihood used by the authors is not actually a good estimate of underlying log likelihood of the model itself. I am willing to believe that the authors might have found something that previous works have missed and am open to be corrected on this.

Author response:
The second point can be separated into GANs as outlier detectors and memorization in GANs:
- We used outlier detection as an inference task to analyze the performance of GANs as density estimators. While the reference given by the reviewer is indeed relevant (and will be added to future versions), all methods for anomaly detection with GANs utilize further components that are not part of the generative model of the GAN. On the other hand, if the GAN were a good density estimator, the generator alone could be utilized for anomaly detection (through likelihood calculations).
- We thank the reviewer for the references regarding memorization and will add them to the related works in future versions. Please note that the authors of reference [4] showed that 7 2-dimensional data points were memorized by a GAN using _tens of thousands of latent codes_. On the other hand, the GANs we analyze model many high-dimensional images, which were augmented during training, so the number of latent codes observed during training (per data point) was much smaller than in [4]. On the other hand, reference [5] analyzes the distribution of nearest neighbors of generated and test samples, showing that the generated samples are slightly closer to the training distribution than the test samples. This could be true even when the GAN can’t _exactly_ reproduce training samples but only generates images that are somewhat more similar to the training data than the test, for instance when there is mode collapse. Conversely, reproducing a training example exactly is a much stronger criterion than being more similar. Does that resolve your concerns regarding memorization?

Reviewer comment (Writing):
Writing wise, while I think most of the paper is clear about the mechanics of the experiments, I would encourage the authors to summarize their contributions clearly at the start of the paper (preferably at the end of the introduction). At several points during reading the paper, I was confused about the exact contributions of the current paper vs contributions from prior work.

Author response:
3. We will take the reviewer’s suggestion and will indeed add a contribution list in future versions. Thank you!

Reviewer comment (Evaluation):
Related to the writing point above, the paper is titled ‘Why are Modern GANs poor density models?’ but I’m still not sure about the exact reason the authors are proposing to be the cause for this phenomenon (poor density modelling). I would encourage the authors to clearly state the reason. The closest I found was in the abstract: “To try and understand the source of this poor performance, we show that the likelihood that a GAN assigns to an input image is dominated by the quality of the GAN reconstruction when only the latent variable is optimized”. This is then again touched on in Section 4 briefly. I would have liked some more analysis about this proposed reason. One such question for example is, do all training samples have similarly bad likelihood? Which modes are represented? (Mode collapse)

Author response:
4. Our view is that GANs are bad density estimator because they assign higher likelihood to images outside the data distribution than to training images, in particular SVHN/flat images. Moreover, the conditional versions of the GANs typically assign the same likelihood to all classes - for instance, StyleGAN2-ADA trained on AFHQCats assigns the same likelihood to images of cats as to images of dogs (this is the reason it’s classification accuracy is close to 50% in figure 3). To try and explain why this happens, we show that the likelihood is largely affected by the GAN’s z-reconstruct quality. The surprising (and in our opinion, interesting) phenomenon is that GANs reconstruct flat/SVHN images much better than training images, which is counter to the intuition that GANs learn the correct data manifold. Moreover, the reconstruction quality of conditional GANs isn’t greatly affected by which class is conditioned on - whether it is truly the correct class or not (like in the cats vs dogs example given earlier). This explains why all GANs had bad performance on OD and generative classification. Regarding what, during training, causes the GAN to learn these solutions - that is a very interesting question but well outside the scope of our submission. Moreover, as the reviewer suggested, this method could be used in order to analyze more fine-grained statistics in GANs, for instance whether some training examples have higher likelihood than others, but this (again) is outside the scope of this submission. Does this answer your questions?

Reviewer comment (Theory):
Conceptually, some aspects of the manuscript are unclear to the reviewer: what is the motivation to frame GANs as density models, since vanilla GANs are not trained with, e.g., maximum (marginal) likelihood objectives. Why would the adversarial loss of GANs lead to good density models and what did the authors expect to find with this study? Can the poor performance of GANs for density estimation tasks be remedied? How does the authors' work fit in the context of related recent literature, such as [2-4].

Author response:
From what we understand, the major concerns of the reviewer were:
1. It is not clear whether GANs should even learn a good density model at all.
2. The significance and novelty of the study with regards to the research of Wu et al.

For these concerns, please see the general comment made regarding GANs as density models and the significance of our research. Briefly, it has been shown that GANs should theoretically learn optimal density models and we hoped that this would be the case - it isn’t, even for state-of-the-art GANs with low FID scores, high sample quality and little to no mode collapse.
In particular, we are not attempting to suggest a new density model, only to analyze existing GANs.

Reviewer comment (Evaluation):
The influence of the stochastic relaxation \(p(x) = \int p(z) p(x | G(z))dz\) on the density estimation is not sufficiently discussed. Could the introduction of the noise lead to lower (or vice versa higher) likelihoods and not the model itself? How is the noise variance chosen?

Author response:
The reviewer is correct, the variance of the stochastic relaxation can indeed influence the relaxed likelihood. As written in section 3, we chose a value for the variance that maximizes this likelihood, which is equal to the variance of the z-reconstruction error.

Reviewer comment (Theory):
Equation 6 introduces a conditional density \(p(z|x)\). It is not clear how this distribution is computed. Also, the equality does apparently not hold. As far as I can tell, the right-hand-side is the evidence lower bound, and hence it is an inequality.

Author response:
Equation 6 is an equivalence, but because it seems that it is not well known, we will add a derivation to the appendix. To see that equation 6 is correct (as long as $p(x)>0$), note that:
$$
    D_{\text{KL}}\left(p(z|x)||p\left(z\right)\right)  =\intop p(z|x)\log\frac{p(z|x)}{p\left(z\right)}dz
  =\intop p(z|x)\left[\log\frac{p(z|x)}{p\left(z\right)}+\log p(x)-\log p(x)\right]dz
  =\mathbb{E}_{z|x}\left[\log p(x|z)\right]-\log p(x)
$$

Reviewer comment (Experiments):
How is the variance of \(\eta\) in Equation 1 chosen? This seems to be a critical hyperparameter.

Author response:
The reviewer is correct, the variance of the stochastic relaxation can indeed influence the relaxed likelihood. As written in section 3, we chose a value for the variance that maximizes this likelihood, which is equal to the variance of the z-reconstruction error.

Reviewer comment (Experiments):
How did you select the classes in ImageNet10 and CIFAR10?

Author response:
The classes for ImageNet10 are a subset of 10 classes from the full ImageNet, which were chosen before any experiments were performed. In CIFAR10, all classes were used.

Reviewer comment (Reproducibility):
How are the baselines fitted? Have KDEs/diagonal Gaussians been fitted for each class or have they been fitted on the pooled data?

Author response:
As the reviewer mentioned, the baselines were trained on each class separately.