TequilaGAN: How To Easily Identify GAN Samples

1 INTRODUCTION . Fake samples generated with the Generative Adversarial Networks ( Goodfellow et al. , 2014a ) framework have fooled humans and machines to believe that they are indistinguishable from real samples . Although this might be true for the naked eye and the discriminator fooled by the generator , it is unlikely that fake samples are numerically indistinguishable from real samples . Inspired by formal methods , this paper focuses on the evaluation of fake samples with respect to statistical summaries and formal specifications computed on the real data . Since the Generative Adversarial Networks paper ( Goodfellow et al. , 2014a ) , most GAN related publications use a grid of image samples to accompany theoretical and empirical results . Unlike Variational Autoencoders ( VAEs ) and other models ( Goodfellow et al. , 2014a ) , most of the evaluation of the output of GAN trained Generators is qualitative : authors normally list higher sample quality as one of the advantages of their method over other methods . Although numerical measures like the inception score are used to evaluate GAN samples ( Salimans et al. , 2016 ) , interestingly , little is mentioned about the numerical properties of fake samples and how these properties compare to real samples . In the context of Verified Artificial Intelligence ( Seshia & Sadigh , 2016 ) , it is hard to systematically verify that the output of a model satisfies the specifications of the data it was trained on , specially when verification depends on the existence of perceptually meaningful features . For example , consider a model that generates images of humans : although it is possible to compare color histograms of real and fake samples , we do not yet have robust algorithms to verify if an image follows specifications derived from anatomy . This paper is related to the systematic verification of fake samples and focuses on comparing numerical properties of fake and real samples . In addition to comparing statistical summaries , we investigate how the Generator approximates modes in the real distribution and verify if the generated samples violate specifications derived from it . We offer the following main contributions : • We show that fake samples have properties that are barely noticed with visual inspection • We show that these properties can be used to identify the source of the data ( real or fake ) • We show that fake samples violate formal specifications learned from real data 2 RELATED WORK . Despite its youth , several publications ( ( Arjovsky & Bottou , 2017 ) , ( Salimans et al. , 2016 ) , ( Zhao et al. , 2016 ) , ( Radford et al. , 2015 ) ) have investigated the use of the GAN framework for sample generation and unsupervised feature learning . Following the procedure described in ( Breuleux et al. , 2011 ) and used in ( Goodfellow et al. , 2014a ) , earlier GAN papers evaluated the quality of the fake samples by fitting a Gaussian Parzen window1 to the fake samples and reporting the log-likelihood of the test set under this distribution . As mentioned in ( Goodfellow et al. , 2014a ) , this method has some drawbacks , including its high variance and bad performance in high dimensional spaces . The inception score is another widely adopted evaluation metric that fails to provide systematic guidance on the evaluation of GAN models ( Barratt & Sharma , 2018 ) . Unlike other optimization problems , where analysis of the empirical risk is a strong indicator of progress , in GANs the decrease in loss is not always correlated with increase in image quality ( Arjovsky et al. , 2017 ) , and thus authors still rely on visual inspection of generated images . Based on visual inspection , authors confirm that they have not observed mode collapse or that their framework is robust to mode collapse if some criteria is met ( ( Arjovsky et al. , 2017 ) , ( Gulrajani et al. , 2017 ) , ( Mao et al. , 2016 ) , ( Radford et al. , 2015 ) ) . In practice , github issues where practitioners report mode collapse or not enough variety abound . In their publications , ( Mao et al. , 2016 ) , ( Arjovsky et al. , 2017 ) and ( Gulrajani et al. , 2017 ) propose alternative objective functions and algorithms that circumvent problems that are common when using the original GAN objective described in ( Goodfellow et al. , 2014a ) . The problems addressed include instability of learning , mode collapse and meaningful loss curves ( Salimans et al. , 2016 ) . These alternatives do not eliminate the need , or excitement2 , to visually inspect GAN samples during training , nor do they provide quantitative information about the generated samples . 3 METHODOLOGY . The experiments in this paper focus on three points : the first shows that fake samples have properties that are hardly noticed with visual inspection and tightly related to the requirements of differentiability ; the second shows that there are numerical differences between statistical moments computed on features extracted from real and fake samples that can be used to identify the data ; the third shows that fake samples violate formal specifications learned from the real data . In the following subsections we enumerate the datasets , features and GAN frameworks herein used . 3.1 DATASETS . In our experiments , we use MNIST , CIFAR10 , a MIDI dataset of 389 Bach Chorales downloaded from the web and a subsample of the NIST 2004 speech dataset used in ( Cai et al. , 2018 ) . 3.2 FEATURES . The spectral centroid ( Peeters , 2004 ) is a feature commonly used in the audio domain , where it represents the barycenter of the spectrum . This feature can be applied to other domains and we invite the reader to visualize Figure 12 for examples on MNIST and Mel-Spectrograms ( Peeters , 2004 ) . For each column in an image , we transform the pixel values into row probabilities by normalizing them by the column sum , after which we take the expected row value , thus obtaining the spectral centroid . The spectral slope adapted from ( Peeters , 2004 ) is computed by applying linear regression using an overlapping sliding window of size 7 . For each window , we regress the spectral centroids on the column number mod the window size . Figure 13 shows these features computed on MNIST and Mel-Spectrograms . 3.3 GAN FRAMEWORKS . We investigate samples produced with the DCGAN architecture using the Least-Squares GAN ( LSGAN ) ( Mao et al. , 2016 ) and the improved Wasserstein GAN ( IWGAN/WGAN-GP ) ( Gulrajani et al. , 2017 ) . We also compare adversarial MNIST samples produced with the fast gradient sign 1Kernel Density Estimation 2Despite of authors promising on Twitter to never train GANs again . method ( FGSM ) ( Goodfellow et al. , 2014b ) . We evaluate the normally used non-linearities , sigmoid and tanh , on the output of the generator and other transformations such as the scaled tanh and identity . 4 EXPERIMENTS . 4.1 MNIST . This experiment focuses on showing numerical properties of fake MNIST samples and features therein , unknown to the naked eye , that can be used to identify them as produced by a GAN . We start by comparing the distribution of features computed over the MNIST training set to other datasets , including the MNIST test set , samples generated with GANs and adversarial samples computed using the FGSM . The training data is scaled to [ 0 , 1 ] and the random baseline is sampled from a Bernoulli distribution with probability equal to the mean value of pixel intensities in the MNIST training data , 0.13 . Each GAN model is trained until the loss plateaus and the generated samples look similar to the real samples . The datasets compared have 10 thousand samples each . Visual inspection of the generated samples in Figure 14 show that IWGAN seems to produce better samples than LSGAN . Quantitatively , we use the MNIST training set as a reference and compare the distribution of pixel intensities . Table 1 reveals that although samples generated with LSGAN and IWGAN look similar to the training set , they are considerably different from the training set given the Kolgomorov-Smirnov ( KS ) Two Sample Test and the Jensen-Shannon Divergence ( JSD ) , specially with respect to the same statistics on the MNIST test data . These numerical phenomena can be understood by investigating the empirical CDFs in Figure 1 . The distribution of pixel values of the samples generated with the GAN framework is mainly bi-modal and asymptotically approaches the modes of the distribution in the real data , values 0 and 1 . Expectedly , the FGSM method , noted as mnist_adversarial , causes a shift on the modes of the distribution that can be easily identified . In addition , plots of the distribution of statistical moments of the spectral centroid in 2 suggests that the fake images are more noisy than the real images . Consider for example images produced by randomly sampling a Bernoulli distribution with parameter estimated from the training data . These images have pixel values of 0 or 1 that are equally distributed 3 over the image . Well , an image that has pixels values distributed in such a manner will have a distribution of mean spectral centroid with a mode at the center row of the image . This and the similarity between the distribution of mean 3This spatial distribution is independent of the parameter of the Bernoulli distribution . spectral centroids from fake data and Bernoulli data suggest that the fake images have noise that are also equally spatially distributed . Last , Figure 3 shows that the GAN generated samples smoothly approximate the modes of the distribution . This smooth approximation is considerably different from the training and test sets . Although not perceptually meaningful , these properties can be used to identify the source of the data . Our first hypothesis for the smooth approximation of the modes of the distribution was that it would be present in any data produced with a generator that is trained using stochastic gradient descent and a saturating activation function , such as sigmoid or tanh , at the output of the generator . To evaluate this hypothesis , we conducted a set of experiments using different GAN architectures ( WGAN-GP , LSGAN , DCGAN ) with different activation functions , including linear and the scaled tanh , at the output of the Generator , keeping the Discriminator fixed . To our surprise , we noticed that the models trained with linear or scaled tanh activations were partially able to produce images that were similar to the MNIST training data and the distribution of pixel intensities , although uni-modal around zero , still possessed a smooth looking curve . This is illustrated in Figure 4 . We then postulated that the smooth behavior was due to smoothness in the pixels intensities of the training data itself . To evaluate this , we binarized the real data by first scaling it between [ 0 , 1 ] and then thresholding it at 0.5 . With this alteration the distribution of the pixel intensities of the real data becomes completely bi-modal with modes at 0 and 1 . Figure 5 shows that the smooth behavior remained . With this empirical evidence at hand , we provide an informal analysis of the smoothness of the distribution of pixels of the generated data from the perspective of optimization , differentiation and function approximation with neural networks . We know that backpropagation and stochastic gradient descent are used to update the weights of a neural network model based on the gradient of the loss with respect to the weights . We also know that differentiation requires the function that is being differentiated to have some high degree of smoothness and be differentiable almost everywhere . Hence , we conjecture that the inductive bias of this learning setup is that of smoothness given the requirements of differentiation . We also speculate that this inductive bias is responsible for the smoothness of the distribution of pixel values at any iteration during training and that the U shape of the distribution of pixel values , similar to blurring , is the byproduct of an smooth approximation of the function that is being learned4 .

Summary: The paper proposes statistics to identify fake data generated using GANs based on simple marginal (summary) statistics or formal specifications automatically generated from real data. The proposed statistics mostly boil down to the fact that continuous-valued generator neural networks can’t adequately generate data distributions that are topologically different from the distribution in the latent z-space. The differences in the summary data/ feature statistics and statistics corresponding to formal specifications between fake and real data are of the above nature.