Title: PIXELDEFEND: LEVERAGING GENERATIVE MODELS TO UNDERSTAND AND DEFEND AGAINST ADVERSARIAL EXAMPLES

Abstract: Adversarial perturbations of normal images are usually imperceptible to humans, but they can seriously confuse state-of-the-art machine learning models. What makes them so special in the eyes of image classifiers? In this paper, we show empirically that adversarial examples mainly lie in the low probability regions of the training distribution, regardless of attack types and targeted models. Using statistical hypothesis testing, we find that modern neural density models are surprisingly good at detecting imperceptible image perturbations. Based on this discovery, we devised PixelDefend, a new approach that purifies a maliciously perturbed image by moving it back towards the distribution seen in the training data. The purified image is then run through an unmodified classifier, making our method agnostic to both the classifier and the attacking method. As a result, PixelDefend can be used to protect already deployed models and be combined with other model-specific defenses. Experiments show that our method greatly improves resilience across a wide variety of state-of-the-art attacking methods, increasing accuracy on the strongest attack from 63% to 84% for Fashion MNIST and from 32% to 70% for CIFAR-10.
Published as a conference paper at ICLR 2018 classifiers mainly due to covariate shift. This is analogous to training models on MNIST (LeCun et al., 1998) but testing them on Street View House Numbers (Netzer et al., 2011) .
To study this hypothesis, we first need to estimate the probability density of the underlying training distribution. To this end, we leverage recent developments in generative models. Specifically, we choose a PixelCNN (van den Oord et al., 2016b) model for its state-of-the-art performance in modeling image distributions (van den Oord et al., 2016a; Salimans et al., 2017) and tractability of evaluating the data likelihood. In the first part of the paper, we show that a well-trained Pixel-CNN generative model is very sensitive to adversarial inputs, typically giving them several orders of magnitude lower likelihoods compared to those of training and test images.
Detecting adversarial examples An important step towards handling adversarial images is the ability to detect them. In order to catch any kind of threat, existing work has utilized confidence estimates from Bayesian neural networks (BNNs) or dropout (Li & Gal, 2017; Feinman et al., 2017) . However, if their model is misspecified, the uncertainty estimates can be affected by covariate shift (Shimodaira, 2000) . This is problematic in an adversarial setting, since the attacker might be able to make use of the inductive bias from the misspecified classifier to bypass the detection.
Protection against the strongest adversary requires a pessimistic perspective-our assumption is that the classifier cannot give reliable predictions for any input outside of the training distribution. Therefore, instead of relying on label uncertainties given by the classifier, we leverage statistical hypothesis testing to detect any input not drawn from the same distribution as training images.
Specifically, we first compute the probabilities of all training images under the generative model. Afterwards, for a novel input we compute the probability density at the input and evaluate its rank (in ascending order) among the density values of all training examples. Next, the rank can be used as a test statistic and gives us a p-value for whether or not the image was drawn from the training distribution. This method is general and practical and we show that the p-value enables us to detect adversarial images across a large number of different attacking methods with high probability, even when they differ from clean images by only a few pixel values.

1. INTRODUCTION:

Recent work has shown that small, carefully chosen modifications to the inputs of a neural network classifier can cause the model to give incorrect labels (Szegedy et al., 2013; Goodfellow et al., 2014) . This weakness of neural network models is particularly surprising because the modifications required are often imperceptible, or barely perceptible, to humans. As deep neural networks are being deployed in safety-critical applications such as self-driving cars (Amodei et al., 2016) , it becomes increasingly important to develop techniques to handle these kinds of inputs.

Rethinking adversarial examples:

The existence of such adversarial examples seems quite surprising. A neural network classifier can get super-human performance (He et al., 2015) on clean test images, but will give embarrassingly wrong predictions on the same set of images if some imperceptible noise is added. What makes this noise so special to deep neural networks?

In this paper, we propose and empirically evaluate the following hypothesis: Even though they have very small deviations from clean images, adversarial examples largely lie in the low probability regions of the distribution that generated the data used to train the model. Therefore, they fool

Purifying adversarial examples Since adversarial examples are generated from clean images by adding imperceptible perturbations, it is possible to decontaminate them by searching for more probable images within a small distance of the original ones. By limiting the L ∞ distance1 , this image purification procedure generates only imperceptible modifications to the original input, so that the true labels of the purified images remain the same. The resulting purified images have higher probability under the training distribution, so we can expect that a classifier trained on the clean images will have more reliable predictions on the purified images. Moreover, for inputs which are not corrupted by adversarial perturbations the purified results remain in a high density region.

We use this intuition to build PixelDefend, an image purification procedure which requires no knowledge of the attack nor the targeted classifier. PixelDefend approximates the training distribution using a PixelCNN model. The constrained optimization problem of finding the highest probability image within an ϵ-ball of the original is computationally intractable, however, so we approximate it using a greedy decoding procedure. Since PixelDefend does not change the classification model, it can be combined with other adversarial defense techniques, including adversarial training (Goodfellow et al., 2014) , to provide synergistic improvements. We show experimentally that PixelDefend performs exceptionally well in practice, leading to state-of-the art results against a large number of attacks, especially when combined with adversarial training.

Contributions Our main contributions are as follows:

• We show that generative models can be used for detecting adversarially perturbed images and observe that most adversarial examples lie in low probability regions. • We introduce a novel family of methods for defending against adversarial attacks based on the idea of purification. • We show that a defensive technique from this family, PixelDefend, can achieve state-of-theart results on a large number of attacking techniques, improving the accuracy against the strongest adversary on the CIFAR-10 dataset from 32% to 70%.

2. BACKGROUND:

2.1 ATTACKING METHODS Given a test image X, an attacking method tries to find a small perturbation ∆ with ∥∆∥ ∞ ≤ ϵ attack , such that a classifier f gives different predictions on X adv ≜ X + ∆ and X. Here colors in the image are represented by integers from 0 to 255. Each attack method is controlled by a configurable ϵ attack parameter which sets the maximum perturbation allowed for each pixel in integer increments on the color scale. We only consider white-box attacks in this paper, i.e., the attack methods can get access to weights of the classifier. In the following, we give an introduction to all the attacking methods used in our experiments.

Random perturbation (RAND) Random perturbation is arguably the weakest attacking method, and we include it as the simplest baseline. Formally, the randomly perturbed image is given by

X adv = X + U(-⌊ϵ attack ⌋, ⌊ϵ attack ⌋),

where U(a, b) denotes an element-wise uniform distribution of integers from [a, b] .

Fast gradient sign method (FGSM) Goodfellow et al. (2014) proposed the generation of malicious perturbations in the direction of the loss gradient ∇ X L(X, y), where L(X, y) is the loss function used to train the model. The adversarial examples are computed by

X adv = X + ϵ attack sign(∇ X L(X, y)).

Basic iterative method (BIM) Kurakin et al. (2016) tested a simple variant of the fast gradient sign method by applying it multiple times with a smaller step size. Formally, the adversarial examples are computed as

X adv 0 = X, X adv n+1 = Clip ϵattack X { X adv n + α sign(∇ X L(X adv n , y)) } ,

where Clip ϵattack X means we clip the resulting image to be within the ϵ attack -ball of X. Following Kurakin et al. (2016) , we set α = 1 and the number of iterations to be ⌊min(ϵ attack + 4, 1.25ϵ attack )⌋. This method is also called Projected Gradient Descent (PGD) in Madry et al. (2017) .

DeepFool DeepFool (Moosavi-Dezfooli et al., 2016) works by iteratively linearizing the decision boundary and finding the closest adversarial examples with geometric formulas. However, compared to FGSM and BIM, this method is much slower in practice. We clip the resulting image so that its perturbation is no larger than ϵ attack .

Carlini-Wagner (CW) Carlini & Wagner (2017b) proposed an efficient optimization objective for iteratively finding the adversarial examples with the smallest perturbations. As with DeepFool, we clip the output image to make sure the perturbations are limited by ϵ attack .

2.2. DEFENSE METHODS:

Current defense methods generally fall into two classes. They either (1) change the network architecture or training procedure to make it more robust, or (2) modify adversarial examples to reduce their harm. In this paper, we take the following defense methods into comparison.

Adversarial training This defense works by generating adversarial examples on-the-fly during training and including them into the training set. FGSM adversarial examples are the most commonly used ones for adversarial training, since they are fast to generate and easy to train. Although training with higher-order adversarial examples (e.g., BIM) has witnessed some success in small datasets (Madry et al., 2017) , other work has reported failure in larger ones (Kurakin et al., 2016) . We consider both variants in our work.

Label smoothing In contrast to adversarial training, label smoothing (Warde-Farley & Goodfellow, 2016 ) is agnostic to the attack method. It converts one-hot labels to soft targets, where the correct class has value 1 -ϵ while the other (wrong) classes have value ϵ/(N -1). Here ϵ is a small constant and N is the number of classes. When the classifier is re-trained on these soft targets rather than the one-hot labels it is significantly more robust to adversarial examples. This method was originally devised to achieve a similar effect as defensive distillation (Papernot et al., 2016c) , and their performance is comparable. We didn't compare to defensive distillation since it is more computationally expensive.

Feature squeezing Feature squeezing (Xu et al., 2017a ) is both attack-agnostic and modelagnostic. Given any input image, it first reduces the color range from [0, 255] to a smaller value, and then smooths the image with a median filter. The resulting image is then passed to a classifier for predictions. Since this technique does not depend on attacking methods and classifiers, it can be combined with other defensive methods such as adversarial training, similar to PixelDefend.

2.3. EXPERIMENT METHODOLOGIES:

Datasets Two datasets are used in our experiments: Fashion MNIST (Xiao et al., 2017) and . Fashion MNIST was designed as a more difficult, but drop-in replacement for MNIST (LeCun et al., 1998) . Thus it shares all of MNIST's characteristics, i.e., 60, 000 training examples and 10, 000 test examples where each example is a 28 × 28 gray-scale image associated with a label from 1 of 10 classes. CIFAR-10 is another dataset that is also broadly used for image classification tasks. It consists of 60, 000 examples, where 50, 000 are used for training and 10, 000 for testing, and each sample is a 32 × 32 color image associated with 1 of 10 classes.

Models:

We examine two state-of-the-art deep neural network image classifiers: ResNet (He et al., 2016) and VGG (Simonyan & Zisserman, 2014) . The architectures are described in Appendix C.

PixelCNN The PixelCNN (van den Oord et al., 2016b; Salimans et al., 2017 ) is a generative model with tractable likelihood especially designed for images. The model defines the joint distribution over all pixels by factorizing it into a product of conditional distributions.

p CNN (X) = ∏ i p CNN (x i |x 1:(i-1) ).

The pixel dependencies are in raster scan order (row by row and column by column within each row). We train the PixelCNN model for each dataset using only clean (not perturbed) image samples. In Appendix D, we provide clean sample images from the datasets as well as generated image samples from PixelCNN (see Figure 8 and Figure 9 ). As a convenient representation of p CNN (X) for images, we also use the concept of bits per dimension, which is defined as BPD(X) ≜ -log p CNN (X)/(I × J × K × log 2) for an image of resolution I × J and K channels.

3. DETECTING ADVERSARIAL EXAMPLES:

Adversarial images are defined with respect to a specific classifier. Intuitively, a maliciously perturbed image that causes one network to give a highly confident incorrect prediction might not fool another network. However, recent work (Papernot et al., 2016a; Liu et al., 2016; Tramèr et al., 2017) has shown that adversarial images can transfer across different classifiers. This indicates that there are some intrinsic properties of adversarial examples that are independent of classifiers.

One possibility is that, compared to normal training and test images, adversarial examples have much lower probability densities under the image distribution. As a result, classifiers do not have enough training instances to get familiarized with this part of the input space. The resulting prediction task suffers from covariate shift, and since all of the classifiers are trained on the same dataset, this covariate shift will affect all of them similarly and will likely lead to misclassifications.

To empirically verify this hypothesis, we train a PixelCNN model on the CIFAR-10 ( Krizhevsky & Hinton, 2009) dataset and use its log-likelihood as an approximation to the true underlying probability density. The adversarial examples are generated with respect to a ResNet (He et al., 2016) , which However, the distribution of log-likelihoods show considerable difference between perturbed images and clean images. As summarized in Figure 2 , even a 3% perturbation can lead to systematic decrease of log-likelihoods. Note that the PixelCNN model has no information about the attacking methods for producing those adversarial examples, and no information about the ResNet model either.

We can see from Figure 3 (b) that random perturbations also push the images outside of the training distribution, even though they do not have the same adverse effect on accuracy. We believe this is due to an inductive bias that is shared by many neural network models but not inherent to all models, as discussed further in Appendix A.

Besides qualitative analysis, the log-likelihoods from PixelCNN also provide a quantitative measure for detecting adversarial examples. Combined with permutation test (Efron & Tibshirani, 1994) , we can provide a uncertainty value for each input about whether it comes from the training distribution or not. Specifically, let the input

X ′ i.i.d. ∼ q(X) and training images X 1 , • • • , X N i.i.d.

∼ p(X). The null hypothesis is H 0 : p(X) = q(X) while the alternative is H 1 : p(X) ̸ = q(X). We first compute the probabilities give by a PixelCNN for

X ′ and X 1 , • • • , X N , then use the rank of p CNN (X ′ ) in {p CNN (X 1 ), • • • , p CNN (X N )} as our test statistic: T = T (X ′ ; X 1 , • • • , X N ) ≜ N ∑ i=1 I[p CNN (X i ) ≤ p CNN (X ′ )].

Here I[•] is the indicator function, which equals 1 when the condition inside brackets is true and otherwise equals 0.

Let T i = T (X i ; X 1 , • • • , X i-1 , X ′ , X i+1 , • • • , X N ).

According to the permutation principle, T i has the same distribution as T under the null hypothesis H 0 . We can therefore compute the p-value exactly by 

p = 1 N + 1 ( N ∑ i=1 I[T i ≤ T ] + 1 ) = T + 1 N + 1 = 1 N + 1 ( N ∑ i=1 I[p CNN (X i ) ≤ p CNN (X ′ )] + 1 ) . (a) (b) (c) (d) (e) (f)

4. PURIFYING IMAGES WITH PIXELDEFEND:

In many circumstances, simply detecting adversarial images is not sufficient. It is often critical to be able to correctly classify images despite such adversarial modifications. In this section we introduce PixelDefend, a specific instance of a new family of defense methods that significantly improves the state-of-the-art performance on advanced attacks, while simultaneously performing well against all other attacks. for each column j do 4:

for each channel k do 5:

x ← X[i, j, k] 6:

Set feasible range R ← [max(x -ϵ defend , 0), min(x + ϵ defend , 255)]

7:

Compute the 256-way softmax p CNN (X * ). We tested two purification methods, L-BFGS-B and greedy decoding, the latter of which is used in PixelDefend. A good purification method should give images that have lower bits per dimension compared to FGSM images and ideally similar bits per dimension compared to clean ones.

4.1. RETURNING IMAGES TO THE TRAINING DISTRIBUTION:

The basic idea behind PixelDefend is to purify input images, by making small changes to them in order to move them back towards the training distribution, i.e., move the images towards a highprobability region. We then classify the purified image using any existing classifier. As the example in Figure 4 shows, the purified images can usually be classified correctly.

Formally, we have training image distribution p(X), and input image X of resolution I × J with X[i, j, k] the pixel at location (i, j) and channel k ∈ {1, • • • , C}. We wish to find an image X * that maximizes p(X) subject to the constraint that X * is within the ϵ defend -ball of X:

max X * p(X * ) s.t. ∥X * -X∥ ∞ ≤ ϵ defend .

Here ϵ defend reflects a trade-off, since large ϵ defend may change the meaning of X while small ϵ defend may not be sufficient for returning X to the correct distribution. In practice, we choose ϵ defend to be some value that overestimates ϵ attack but still keeps high accuracies on clean images. As in Section 3, we approximate p(X) with the PixelCNN distribution p CNN (X), which is trained on the same training set as the classifier.

However, exact constrained optimization of p CNN (X) is computationally intractable. Surprisingly, even gradient-based optimization faces great difficulty on that problem. We found that one advanced methods in gradient-based constrained optimization, L-BFGS-B (Byrd et al., 1995) (we use the scipy implementation based on Zhu et al. (1997) ), actually decreases p CNN (X) for most random initializations within the ϵ defend -ball.

Published as a conference paper at ICLR 2018 For efficient optimization, we instead use a greedy technique described in Algorithm 1, which is similar to the greedy decoding process typically used in sequence-to-sequence models (Sutskever et al., 2014) . The method is similar to generating images from PixelCNN, with the additional constraint that the generated image should be within an ϵ defend -ball of a perturbed image. As an autoregressive model, PixelCNN is slow in image generation. Nonetheless, by caching redundant calculation, Ramachandran et al. (2017) proposes a very fast generation algorithm for PixelCNN. In our experiments, adoption of Ramachandran et al. ( 2017)'s method greatly increases the speed of PixelDefend. For CIFAR-10 images, PixelDefend on average processes 3.6 images per second on one NVIDIA TITAN Xp GPU. To show the effectiveness of this greedy method compared to L-BFGS-B, we take the first 10 images from CIFAR-10 test set, attack them by FGSM with ϵ attack = 8, and purify them with L-BFGS-B and PixelDefend respectively. We used random start points for L-BFGS-B and repeated 100 times for each image. As depicted in Figure 5 , most L-BFGS-B attempts failed at minimizing the bits per dimension of FGSM adversarial examples. Because of the rugged gradient landscape of PixelCNN, L-BFGS-B even results in images that have lower probabilities. In contrast, PixelDefend works much better in increasing the probabilities of purified images, although their probabilities are still lower compared to clean ones.

In Figure 6 and Figure 7 , we empirically show that after PixelDefend, purified images are more likely to be drawn from the training distribution. Specifically, Figure 6 shows that the detecting power of p-values greatly decreases for purified images. For DeepFool and CW examples, purification makes them barely distinguishable from normal samples of the data distribution. This is also manifested by Figure 7 , as the p-value distributions of purified examples are closer to uniform. Visually, purified images indeed look much cleaner than adversarially perturbed ones. In Appendix E, we provide sampled purified images from Fashion MNIST and CIFAR-10.

4.2. ADAPTIVE PIXELDEFEND:

One concern with the approach of purifying images is what happens when we purify a clean image. More generally, we will never know ϵ attack and if we set ϵ defend too large for a given attack, then we will modify all images to become the mode image, which would mostly result in misclassifications.

One way to avoid this problem is to tune ϵ defend adaptively based on the probability of the input image under the generative model. In this way, images that already have high probability under the training distribution would have a very low ϵ defend preventing significant modification, while low probability images would have a high ϵ defend thus allowing significant modifications. We implemented a very simple thresholding version of this, which sets ϵ defend to zero if the input image probability is below a threshold value, and otherwise leaves it fixed at a manually chosen setting. In practice, we set this threshold based on knowledge of the set of possible attacks, so strictly speaking, the adaptive version of our technique is no longer attack-agnostic. The cells in Tab. 1 is formated as x/y, where x denotes the accuracy (%) on images attacked with ϵ attack = 8, while y denotes the accuracy when ϵ attack = 25. For CIFAR-10 (Tab. 2), we tried ϵ attack = 2, 8, and 16, and the cells are formated in a similar way. We use the same ϵ defend for different ϵ attack 's to show that PixelDefend is insensitive to ϵ attack .

From the tables we observe that adversarial training successfully defends against the basic FGSM attack, but cannot defend against the more advanced ones. This is expected, as training on simple adversarial examples does not guarantee robustness to more complicated attacking techniques. Consistent with Madry et al. (2017) , adversarial training with BIM examples is more successful at preventing a wider spectrum of attacks. For example, it improves the accuracy on strongest attack from 2% to 32% on CIFAR-10 when ϵ attack = 8. But the numbers are still not ideal even with respect to BIM attack itself. As in Tab. 2, it only gets 6% on BIM and 8% on CW when ϵ attack = 16. We also observe that label smoothing, which learns smoothed predictions so that the gradient ∇ X L(X, y) becomes very small, is only effective against simple FGSM attack. Model-agnostic methods, such as feature squeezing, can be combined with other defenses for strengthened performance. We observe that combining it with adversarial training indeed makes it more robust. Actually, Tab. 1 and Tab. 2 show that feature squeezing combined with adversarial training dominates using feature squeezing along in all settings. It also gets good performance on DeepFool and CW attacks. However, for iterative attacks with larger perturbations, i.e., BIM, feature squeezing performs poorly. On CIFAR-10, it only gets 2% and 0% accuracy on BIM with ϵ attack = 8 and 16 respectively.

PixelDefend, our model-agnostic and attack-agnostic method, performs well on different classifiers (ResNet and VGG) and different attacks without modification. In addition, we can see that augmenting basic adversarial training with PixelDefend can sometimes double the accuracies. We hypothesize that the purified images from PixelDefend are still not perfect, and adversarially trained networks have more toleration for perturbations. This also corroborates the plausibility and benefit of combining PixelDefend with other defenses.

Furthermore, PixelDefend can simultaneously obtain accuracy above 70% for all other attacking techniques, while ensuring that performance on clean images only declines slightly. Models with PixelDefend consistently outperform other methods with respect to the strongest attack. On Fashion MNIST, PixelDefend methods improve the accuracy on strongest attack from 76% to 85% and 63% to 84%. On CIFAR-10, the improvements are even more significant, i.e., from 74% to 81%, 32% to 70% and 6% to 56%, for ϵ attack = 2, 8, and 16 respectively. In a security-critical scenario, the weakest part of a system determines the overall reliability. Therefore, the outstanding performance of PixelDefend on the strongest attack makes it a valuable and useful addition for improving AI security.

4.4. END-TO-END ATTACK OF PIXELDEFEND:

A natural question that arises is whether we can generate a new class of adversarial examples targeted specifically at the combined PixelDefend architecture of first purifying the image and then using an existing classifier to predict the label of the purified image. We have three pieces of empirical evidence to believe that such adversarial examples are hard to find in general. First, we attempted to apply the iterative BIM attack to an end-to-end differentiable version of PixelDefend generated by unrolling the PixelCNN purification process. However we found the resulting network was too deep and led to problems with vanishing gradients (Bengio et al., 1994) , resulting in adversarial images that were identical to the original images. Moreover, attacking the whole system is very time consuming. Empirically, it took about 10 hours to generate 100 attacking images with one TITAN Xp GPU which failed to fool PixelDefend. Secondly, we found the optimization problem in Eq. (4.1) was not amenable to gradient descent, as indicated in Figure 5 . This makes gradient-based attacks especially difficult. Last but not least, the generative model and classifier are trained separately and have independent parameters. Therefore, the perturbation direction that leads to higher probability images has a smaller correlation with the perturbation direction that results in misclassification. Accordingly, it is harder to find adversarial examples that can fool both of them together. However, we will open source our codes and look forward to any possible attack from the community.

5. RELATED WORK:

Most recent work on detecting adversarial examples focuses on adding an outlier class detection module to the classifier, such as Grosse et al. (2017) , Gong et al. (2017) and Metzen et al. (2017) .

Those methods require the classification model to be changed, and are thus not model-agnostic. Feinman et al. ( 2017) also presents a detection method based on kernel density estimation and Bayesian neural network uncertainty. However, Carlini & Wagner (2017a) shows that all those methods can be bypassed. (Papernot et al., 2016b) . We show the efficacy of PixelCNN on a wider range of attacking methods (see Figure 3 ), including both first-order and iterative methods. Third, we further demonstrate that random perturbed inputs are also outside of the training distribution.

Some other work has focused on modifying the classifier architecture to increase its robustness, e.g., Gu & Rigazio (2014) , Cisse et al. (2017) and Nayebi & Ganguli (2017) . Although they have witnessed some success, such modifications of models might limit their representative power and are also not model-agnostic.

Our basic idea of moving points to higher-density regions is also present in other machine learning methods not specifically designed for handling adversarial data; for example, the manifold denoising method of Hein & Maier (2007) , the direct density gradient estimation of Sasaki et al. (2014) , and the denoising autoencoders of Vincent et al. (2008) all move data points from low to high-density regions. In the future some of these methods could be adapted to amortize the purification process directly, that is, to learn a purification network.

6. CONCLUSION:

In this work, we discovered that state-of-the-art neural density models, e.g., PixelCNN, can detect small perturbations with high sensitivity. This sensitivity broadly exists for a large number of perturbations generated with different methods. An interesting fact is that PixelCNN is only sensitive in one direction-it is relatively easy to detect perturbations that lead to lower probabilities rather than higher probabilities.

Based on the sensitivity of PixelCNN, we utilized statistical hypothesis testing to verify that adversarial examples lie outside of the training distribution. With the permutation test, we give exact p-values which can be used as a uncertainty measure for detecting outlier perturbations. 

:

We note that there are many other ways of defining distance of images. In this paper we use L ∞ norm.

* The same architecture is used for both CIFAR-10 and Fashion MNIST, but different numbers of feature maps are used. The number of feature maps in parentheses is for Fashion MNIST.

Figures and Tables:

Figure 1: An image sampled from the CIFAR-10 test dataset and various adversarial examples generated from it. The text above shows the attacking method while the text below shows the predicted label of the ResNet.

Figure 2: (a) Likelihoods of different perturbed images with ϵ attack = 8. (b) Test errors of a ResNet on different adversarial examples.

Figure 3: The distribution of p-values under the PixelCNN generative model. The inputs are more outside of the training distribution if their p-value distribution has a larger deviation from uniform. Here "clean" means clean test images. From definition, the p-values of clean training images have a uniform distribution.

Figure 4: An example of how purification works. The above row shows an image from CIFAR-10 test set and various attacking images generated from it. The bottom row shows corresponding purified images. The text below each image is the predicted label given by our ResNet.

Figure 5: The bits-per-dimension distributions of purified images from FGSM adversarial examples.We tested two purification methods, L-BFGS-B and greedy decoding, the latter of which is used in PixelDefend. A good purification method should give images that have lower bits per dimension compared to FGSM images and ideally similar bits per dimension compared to clean ones.

Figure 6: ROC curves showing the efficacy of using p-values as scores to detect adversarial examples. For computing the ROC, we assign negative labels to training images and positive labels to adversarial images (or clean test images). (a) Original adversarial examples. (b) Purified adversarial examples after PixelDefend.

Figure 7: The distributions of p-values under the PixelCNN model after PixelDefend purification.

Figure 11: The upper part shows adversarial images generated from FGSM attack while the bottom part shows corresponding purified images by PixelDefend. Here ϵ attack = 8 and ϵ defend = 16.

Algorithm 1 PixelDefend Input: Image X, Defense parameter ϵ defend , Pre-trained PixelCNN model p CNN Output: Purified Image X

Table content: <table/>

Fashion MNIST (ϵ attack = 8/25, ϵ defend = 32)

Table content: <table><tr><td>NETWORK</td><td>TRAINING TECHNIQUE</td><td colspan="3">CLEAN RAND FGSM</td><td>BIM</td><td>DEEP FOOL</td><td>CW</td><td>STRONGEST ATTACK</td></tr><tr><td>ResNet</td><td>Normal</td><td>93/93</td><td>89/71</td><td>38/24</td><td>00/00</td><td>06/06</td><td>20/01</td><td>00/00</td></tr><tr><td>VGG</td><td>Normal</td><td>92/92</td><td>91/87</td><td>73/58</td><td>36/08</td><td>49/14</td><td>43/23</td><td>36/08</td></tr><tr><td/><td>Adversarial FGSM</td><td>93/93</td><td>92/89</td><td>85/85</td><td>51/00</td><td>63/07</td><td>67/21</td><td>51/00</td></tr><tr><td/><td>Adversarial BIM</td><td>92/91</td><td colspan="2">92/91 84/79</td><td>76/63</td><td>82/72</td><td>81/70</td><td>76/63</td></tr><tr><td>ResNet</td><td>Label Smoothing Feature Squeezing</td><td>93/93 84/84</td><td>91/76 84/70</td><td>73/45 70/28</td><td>16/00 56/25</td><td>29/06 83/83</td><td>33/14 83/83</td><td>16/00 56/25</td></tr><tr><td/><td>Adversarial FGSM + Feature Squeezing</td><td>88/88</td><td>87/82</td><td>80/77</td><td>70/46</td><td>86/82</td><td>84/85</td><td>70/46</td></tr><tr><td>ResNet</td><td>Normal + PixelDefend</td><td>88/88</td><td>88/89</td><td>85/74</td><td>83/76</td><td>87/87</td><td>87/87</td><td>83/74</td></tr><tr><td>VGG</td><td>Normal + PixelDefend</td><td>89/89</td><td>89/89</td><td>87/82</td><td>85/83</td><td>88/88</td><td>88/88</td><td>85/82</td></tr><tr><td>ResNet</td><td>Adversarial FGSM + PixelDefend</td><td>90/89</td><td>91/90</td><td>88/</td><td/><td/><td/><td/></tr></table>

We carried out a comprehensive set of experiments to test various defenses versus attacks. Detailed information on experimental settings is provided in Appendix B. All experimental results are summarized in Tab. 1 and Tab. 2. In the upper part of the tables, we show how the various baseline defenses fare against each of the attacks, while in the lower part of the tables we show how our PixelDefend technique works. Each table cell contains accuracies on adversarial examples generated with different ϵ attack . More specifically, for Fashion MNIST (Tab. 1), we tried ϵ attack = 8 and 25.

Table content: <table><tr><td>Adversarial FGSM +Adaptive PixelDefend</td><td>91/91</td><td>91/91 88/88 85/84 89/90 89/84</td><td>85/84</td></tr><tr><td>4.3 PIXELDEFEND RESULTS</td><td/><td/><td/></tr></table>

CIFAR-10 (ϵ attack = 2/8/16, ϵ defend = 16)

Table content: <table><tr><td>NETWORK</td><td>TRAINING TECHNIQUE</td><td>CLEAN</td><td>RAND</td><td>FGSM</td><td>BIM</td><td>DEEP FOOL</td><td>CW</td><td>STRONGEST ATTACK</td></tr><tr><td>ResNet</td><td>Normal</td><td colspan="3">92/92/92 92/87/76 33/15/11</td><td>10/00/00</td><td>12/06/06</td><td>07/00/00</td><td>07/00/00</td></tr><tr><td>VGG</td><td>Normal</td><td colspan="3">89/89/89 89/88/80 60/46/30</td><td>44/02/00</td><td>57/25/11</td><td>37/00/00</td><td>37/00/00</td></tr><tr><td/><td>Adversarial FGSM</td><td colspan="4">91/91/91 90/88/84 88/91/91 24/07/00</td><td>45/00/00</td><td>20/00/07</td><td>20/00/00</td></tr><tr><td/><td>Adversarial BIM</td><td colspan="3">87/87/87 87/87/86 80/52/34</td><td>74/32/06</td><td>79/48/25</td><td>76/42/08</td><td>74/32/06</td></tr><tr><td>ResNet</td><td>Label Smoothing Feature Squeezing</td><td colspan="3">92/92/92 91/88/77 73/54/28 84/84/84 83/82/76 31/20/18</td><td>59/08/01 13/00/00</td><td>56/20/10 75/75/75</td><td>30/02/02 78/78/78</td><td>30/02/01 13/00/00</td></tr><tr><td/><td>Adversarial FGSM + Feature Squeezing</td><td colspan="3">86/86/86 85/84/81 73/67/55</td><td colspan="3">55/02/00 85/85/85 83/83/83</td><td>55/02/00</td></tr><tr><td>ResNet</td><td>Normal + PixelDefend</td><td colspan="3">85/85/88 82/83/84 73/46/24</td><td>71/46/25</td><td>80/80/80</td><td>78/78/78</td><td>71/46/24</td></tr><tr><td>VGG</td><td>Normal + PixelDefend</td><td colspan="3">82/82/82 82/82/84 80/62/52</td><td>80/61/48</td><td>81/76/76</td><td>81/79/79</td><td>80/61/48</td></tr><tr><td>ResNet</td><td>Adversarial FGSM + PixelDefend</td><td colspan="6">88/88/86 86/86/87 81/68/67 81/69/56 85/85/85 84/84/84</td><td>81/69/56</td></tr><tr><td/><td>Adversarial FGSM + Adaptive PixelDefend</td><td colspan="5">90/90/90 86/87/87 81/70/67 81/70/56 82/81/82</td><td>81/80/81</td><td>81/70/56</td></tr></table>

Grosse et al. (2017) also studied the distribution of adversarial examples from a statistical testing perspective. They reported the same discovery that adversarial examples are outside of the training distribution. However, our work is different from theirs in several important aspects. First, the kernel-based two-sample test used in their paper needs a large number of suspicious inputs, while our method only requires one data point. Second, they mainly tested on first-order methods such as FGSM and JSMA

Table content: <table/>

Peer review (iclr2018):
 The authors propose to use a generative model of images to detect and defend against adverarial examples. White-box attacks against standard models for image recognition (Resnet and VGG) are considered, and a generative model (a PixelCNN) is trained on the same data as the classifiers. The authors first show that adversarial examples created by the white-box attacks correspond to low likelihood region (according to the pixelCNN), which first gives a classification rule for detecting adversarial examples. Then, to turn the genrative model into a defensive algorithm, the authors propose to preprocess test images by approximately maximizing the likelihood under similar constraints as the attacker of images, to "project" adversarial examples back to high-density regions (as estimated by the generative model). As a heuristic method, the authors propose to greedily maximize the likelihood of the incoming images pixel-by-pixel, which is possible because of the specific form of the PixelCNN likelihood in the context of l-infty attacks. An "adaptive" version of the algorithm, in which the preprocessing is used only when the likelihood of an example is below a certain threshold, is also proposed. Experiments are carried out on Fashion MNIST and CIFAR-10. At a high level, the message is that projecting the image into a high density region is sufficient to correct for a significant portions of the mistakes made on adversarial examples. The main result is that this approach based on generative models seems to work even on against the strongest attacks. Overall, the idea proposed in the paper, using a generative model to detect and filter out spurious patterns that can appear in adversarial examples, is rather intuitive. The experimental result that adversarial examples can somehow be corrected by a generative model is also interesting. The design choice of PixelCNN, which allows for a greedy optimization seems reasonable in that setting. Whereas the paper is an interesting step forward, the paper still doesn*t provide definitive arguments in favor of using such approaches in practice. There is a significant loss in accuracy on clean examples (2% on CIFAR-10 for a resnet), and more generally against weaker opponents such as the fast gradient sign. Thus, in reality, the experiments show that the pipeline generative model + classifier is robust against the strongest white box methods for this classifier, but on the other hand these methods do not transfer well to new models. This somewhat weakens the result, since robustness against these methods that do not transfer well is achieved by changing the model.