P IXEL R EDRAWN F OR A R OBUST A DVERSARIAL D EFENSE
Anonymous authors
Paper under double-blind review
A BSTRACT
Recently, an adversarial example becomes a serious problem to be aware of because it can fool trained neural networks easily.
To prevent the issue, many researchers have proposed several defense techniques such as adversarial training, input transformation, stochastic activation pruning, etc.
In this paper, we propose a novel defense technique, Pixel Redrawn (PR) method, which redraws every pixel of training images to convert them into distorted images.
The motivation for our
PR method is from the observation that the adversarial attacks have redrawn some pixels of the original image with the known parameters of the trained neural network.
Mimicking these attacks, our PR method redraws the image without any knowledge of the trained neural network.
This method can be similar to the adversarial training method but our PR method can be used to prevent future attacks.
Experimental results on several benchmark datasets indicate our PR method not only relieves the over-ﬁtting issue when we train neural networks with a large number of epochs, but it also boosts the robustness of the neural network.
I NTRODUCTION
Deep neural networks have exhibited very accurate results, but, are also vulnerable to adversarial examples (Szegedy et al., 2013).
Adversarial example is a generated output that induces a trained machine to misclassify a test datum with a high probability.
In other words, the adversarial example can fool the trained machine to fail its task (Dhillon et al., 2018b; Goodfellow et al., 2014; Szegedy et al., 2013).
We call the method that generates adversarial examples as an attack technique.
For instance, in image classiﬁcation, an attack technique is creating an adversarial image by perturbing some pixels of the original image in which the adversarial image is remained to be perceptible by the human.
Obviously, the lesser the pixels to be perturbed, the better the attack technique it is.
Defense techniques to prevent those attacks usually need to produce a robust neural network model which can detect adversarial examples or label the adversarial examples correctly.
There are many researchers who have studied both attacking and defense techniques, and it is generally believed that the defense techniques are more challenging than the attack techniques.
In this paper, we focus on the defense technique that generates a robust neural network.
For this purpose, we have to understand the fundamental idea of generating the adversarial example.
In image classiﬁcation, usually, an adversarial image is generated by perturbing its pixels’ value (for example, L 2 or L ∞ attack).
If we regard the perturbed pixels to be formed by adding some noises, then the technique of creating the noises can be recognized as a dropout (Srivastava et al., 2014)
(if the perturbed pixel value is zero) or other regularization techniques (Adeli & Wu, 1998; Krogh &
Hertz, 1992; Nowlan & Hinton, 1992).
The neural network with the regularization method usually shows higher performance than the one without the regularization method (normal testing).
From another viewpoint, we can regard adversarial examples as a subset from the training dataset universe.
Due to the difﬁculty of collecting all possible examples in the world, we usually just use the clean (unperturbed) examples (Kurakin et al., 2016b; Yuan et al., 2017) as the representative of our training dataset.
In order to solve the problem, we propose Pixel Redrawn (PR) method, which is a pre-processing method that redraws a pixel value of the original image into a different pixel value.
The PR method is motivated by two observations.
The ﬁrst observation is based on the lesson provided by Carlini and
Wagner in (Carlini & Wagner, 2017), which the randomization can increase the distortion required for attack.
The paper has mentioned that the most effective defense technique so far is the dropout randomization which has increased nearly ﬁve times more difﬁculty in generating the adversarial examples on CIFAR dataset.
We agree that the randomization method makes it difﬁcult to compute the derivation during the back-propagation and it could replace the perturbed pixel with another value by some random chances during the feed-forward.
The second observation is that humans usually can recognize images regardless of the colors in which the image has been drawn (e.g. in various colors or in gray level).
This indicates that we usually (human) may not need to have a colorful image just for image classiﬁcation.
We discuss this in more detail with our proposed method in Section 2.
In this study, we focus on the following:
• We analyze the inﬂuence of our PR method toward a normal deep neural network without any adversarial machine learning.
• We evaluate the effectiveness of our PR method applied in the deep neural network against the adversarial example.
And, we compare our PR method with a random noise injection.
Our research contributions can be summarized as follows:
• Our PR method effectively generates adversarial training images that are not covered in the original dataset.
• Hence, our PR method increases the robustness in neural network training.
To promote reproducible research, we release the implementation of our defense.
P IXEL R EDRAWN M ETHOD 2. P RELIMINARIES
Let X be the image for the input of neural networks.
If the size of the image is m × n , then { x i | x i ∈
X } , where x i = x 1 , x 2 , . .
, x m × n is the pixel of the image.
A classiﬁer F ( · ) is a function to produce a predicted label (cid:98) Y for X .
Let Y be the true label of image X .
An attack technique A ( · ) is a function to generate an adversarial image X adv from X with (or without) the knowledge of F ( · ) .
2. O UR A PPROACH
As aforementioned, PR is a pre-processing method PR ( · ) which reproduces a new image by redrawing the pixels of the original image.
We called the generated image as PR image X pr .
We list the three main steps of PR method as follows:
Discretization Let C be the range of color C ∈ [0 , 255] .
Note that we use a normalized pixel value C ∈ [0 , 1] in the experiment section (Section 4).
If we discretize the color into k sets, then { c i | c i ∈ C } , where c
i = c 1 , c 2 , . . .
, c k is the sub-range of color in C .
For each c i , the range starts from a minimum value s pri min and ends with a maximum value s pri max (e.g. c 1 =
[ s pr 1 min , s pr 1 max ] =
[0 , 51] if k = 5 and C is equally divided).
Prediction We train a PR model (describe more in Section 2.3) and then we use it to predict each pixel of an image.
[Equation]
where ˆ y pri is a prediction label of a pixel from PR model, w is a weight of PR model, x i is a pixel of an image, and b is a bias of PR model (shown in ‘PR process’ of Fig. 1).
[Equation]
where colorset ( · ) is the color set that has deﬁned by the user,
c i is the sub-range of color with a minimum value s pri min and a maximum value s pri max , and random c i ( · ) is a random function that generates a random value between s pri min and s pri max .
In Fig.
1, we perform pre-processing (PR process) for the original image.
We reassign each pixel of the image to a random value, such that the range of the random value is based on the chosen sub-range of color which is predicted from PR model.
The newly generated PR image is then fed into a neural network.
We depict some examples from a real dataset (i.e. MNIST (LeCun et al., 1998) dataset) with PR method in Fig.
The intuition of redrawing each pixel with a certain value in an accepted interval is that, for a certain training image, the training dataset does not include all possible combination of the training image with human-acceptably varying pixel values.
With the PR method, we try to include those missing data in the training phase.
Another advantage of using the PR method is that we can generate more accurate neural network models (discussed in more detail in Section 2.5).
In the following sub-sections, we explain PR model for effectively generating new pixel redrawn images by our PR method
. 2. G ENERATING P IXEL R EDRAWN M ODEL
Given a pixel value from the original training image x i , PR model predicts the output pixel value ˆ y pri , perturbed within an accepted range
c i , for the corresponding pixel location of the new image x pri .
Since we redraw each pixel of the image (either grayscale or color) independently which the pixel is the only input for the PR model, and we need the PR model to produce several outputs, then single-layer Perceptron is qualiﬁed in this case.
Firstly, we train the PR model by generating a batch of random examples with the corresponding labels initialized with the c i .
After the PR model is converged, we predict each pixel of the original image with the newly trained PR model.
Lastly, we assign a predicted output value of the winning node at the last layer in the trained PR model to the corresponding pixel location of the new image.
Note that the output value is within the accepted range which is initialized by the user.
The ﬁnal output should look similar as the right-hand side image of a pair image in Fig. 2).
2. P SEUDO - CODE OF THE P IXEL R EDRAWN M ETHOD
In order to have a clear description of our proposed method, we provide the pseudo-code of the
PR method in Algorithm 1.
First, we initialize the settings of the PR models, which include the range of each color value
c
i , the number of the input (always 1) and output ( k ) , the number of the epochs/iterations, and some random weights.
Then, we train the PR model by generating some random inputs with a corresponding label which the label is based on the range of each color value.
After we train the PR model, we generate a PR image ( X pr ) by using the trained PR model to redraw all pixels of the original image ( X ).
Next, we use the newly generated PR image ( X pr ) as the input of the neural network during the training phase and testing phase.
In the end, the trained network show the output label of the test data.
2. E XTENSION OF THE P IXEL R EDRAWN M ODEL
One direct extension is using multiple PR models.
We train d PR models and predict each pixel of the original image with one of the trained PR models.
In other words, we randomly select one PR model out of d PR models to predict a pixel of the original image.
Then, we repeat the same steps until all pixels are redrawn.
Another extension is partially converged PR models (less accurate) to redraw a pixel to a totally different color value.
The partially converged PR model is generated when we prematurely stop the training phase on purpose after a few epochs so that the model is not fully trained.
For example, if a black and white ( k = 2) PR model has 70% accuracy to predict a pixel either black or white color, then a black color pixel can have 30% chance to be converted into a white color.
Note that this may or may not inﬂuence the content of the image depending on the number of the pixels that are different from the original input.
In the extreme case, PR method may able to change an eye color from black to blue for example, by using the partially converged PR models.
The motivation of using the partially converged PR models is because the adversarial example changes a pixel value into a different value which the changed value is far from the original value ( L ∞ attack).
In summary, using several PR models (including some partially converged PR models) increase the robustness of the neural network.
E XPERIMENTAL S ETTINGS 3. D ATASET
For experimental analysis of our propose methods, we use three public benchmark datasets in this study.
The datasets include MNIST, Fashion MNIST (Xiao et al., 2017) and CIFAR-10 (Krizhevsky et al., 2010).
For the CIFAR-10 dataset, we generate another grayscale CIFAR-10 for the purpose of analyzing the inﬂuence of our proposed method on the color image.
MNIST and Fashion MNIST have 60,000 training images and 10,000 test images associated with a label from ten classes.
The size of each image is 28 × 28 grayscale.
CIFAR-10, however, has 50,000 training images and 10, test images with ten classes.
Each image is 32 × 32 color image.
We use a basic convolutional neural network (CNN) (Krizhevsky et al., 2012) as the neural network architecture for all datasets.
The neural network architecture is shown in Fig.
We use three convolutional layers and one fully connected layer.
The convolutional layers are followed by the
Rectiﬁer Linear Unit (ReLU) activation function.
The fully connected layer is followed by the
Softmax activation function.
3. ATTACK TECHNIQUE
There are two kinds of attacks, which are white-box attack and black-box attack.
In the whitebox attack, attackers know all parameters of the attacked model, whereas in the black-box attack, attackers have no knowledge about the parameters of the attacked model.
In this experiment, we run the white-box attack because it is the hardest to defend.
The attack can be targeted attack or untargeted attack.
In the targeted attack, the attacker tries to deceive the trained network to misclassify the datum as the targeted label.
The untargeted attack, on the other hand, is fooling the trained model to misclassify the datum as any label except the true label.
We choose the untargeted attack in the experiment because it is easier for the attacker than the targeted attack.
We use several state-of-the-art attack techniques for the evaluation of our proposed method.
The attack techniques include Fast Gradient Sign Method (FGSM)
(Goodfellow et al., 2014), basic iterative method (BIM) (Kurakin et al., 2016a), momentum iterative method (MIM) (Dong et al., 2018) and L 2 -Carlini & Wagner’s
( L 2 -CW)
(Carlini & Wagner, 2016) attack.
During the experiments, when we apply with the FGSM, BIM, and MIM attacks, we set (cid:15) = 0 .
3 for the MNIST dataset and (cid:15)
=
for the Fashion MNIST and CIFAR-10 datasets .
For CW attack, we set 1,000 in the number of iterations to run the attack.
FGSM It is a fast and simple attack technique to generate the adversarial example which has proposed by Goodfellow et al.
We set this technique as the baseline of attack techniques.
The equation of FGSM is computed by
[Equation]
where (cid:15) is the maximum perturbation allowed for each pixel and L ( X, y ) is a loss function.
BIM
It is an extension of FGSM by applying multiple iterations with small step size in order to obtain the least perturbations of the image.
This technique is proposed by Kurakin et al.
(2016a).
The computation of the technique is shown in Eq.
[Equation]
where Clip X,(cid:15) is a function to clip the output image to be within the (cid:15) -ball of X.
MIM It is more advanced than BIM with momentum algorithm.
This technique is proposed by Dong et al.
The computation of the technique is shown in Eq.
[Equation]
where g t +1 is shown in Eq.
[Equation]
CW It is an efﬁcient attack technique in ﬁnding the adversarial example with the smallest perturbations.
The equation is shown as follow.
[Equation] [Equation]
3. D EFENSE T ECHNIQUE
We categorize the defense techniques into two different categories.
They are white-box defense and black-box defense.
In the white-box defense, defenders use only the known attack techniques to generate adversarial examples to be included in a training dataset (e.g. adversarial training (Goodfellow et al., 2014; Madry et al., 2017; Tram`er et al., 2017)).
In the black-box defense, on the other hand, defenders have no knowledge about the attack techniques and they try to generate a robust neural network model (e.g. stochastic activation pruning (SAP) (Dhillon et al., 2018a), input transformations (Guo et al., 2018), etc.).
The white-box defense is usually performed better than the black-box defense because it can use the state-of-the-art attack technique to create adversarial examples for the training purpose and then the trained model can prevent the attacks with the similar level (or weaker levels) of the known attack technique.
However, unlike the black-box defense, the white-box defense might not be able to defend strong attacks devised in the future.
Due to the disability of the white-box defense in defending future attacks, the black-box defense is more reliable to be studied.
Therefore, most state-of-the-art defense techniques are the black-box defense.
3. C ASE S TUDY WITH D IFFERENT A TTACK S CENARIOS
In this paper, we evaluate our method in several cases with different attack scenarios.
The case studies are included as follows:
• Normal: No attack technique is used.
Test the neural networks with a legitimate datum.
(cid:98) Y = F ( PR ( X ))
• Case A:
The attackers have no knowledge of the PR method but they knows the parameters of the trained neural networks.
The attackers create an adversarial image from an image with the parameters of the trained neural networks.
The defense mechanism receives the adversarial image as the input for the PR model and then generate PR image for the input of the trained neural networks.
(cid:98) Y = F ( PR ( A ( F, X )))
• Case B: No PR method is used during the testing phase.
The attackers have no knowledge of PR method but they knows the parameters of the trained neural networks.
The attackers generate an adversarial image from an image with the parameters of the trained neural networks.
The trained neural networks use the adversarial image as the input without being pre-processed by the PR method.
(cid:98) Y = F ( A ( F, X ))
• Case C:
The attackers know both the PR method and the trained neural networks.
The attackers produce an adversarial image from an image with the parameters of the PR method and trained neural network.
The trained neural networks use the adversarial image as the input without being pre-processed by the PR method.
(cid:98) Y = F ( A ( F, PR, X ))
• Case D: The attackers know both the PR method and the trained neural networks.
The attackers produce an adversarial image from an image with the parameters of the PR method and trained neural network.
The defense mechanism receives the adversarial image as the input for the PR model and the newly created PR image is used as the input of the trained neural networks.
(cid:98) Y = F ( PR ( A ( F, PR, X )))
We illustrate some adversarial images generated from the MNIST dataset for each case in Fig.
Note that the adversarial example generated from the case C and D can cause high L 0 , L 2 and L ∞ distances because the attacker has used a distorted image instead of a clean image.
In other words, the perturbed pixels from the adversarial image can be perceptible by the human.
E XPERIMENTAL R ESULTS
In this study, we perform several experiments based on the following questions:
What is the inﬂuence of applying the PR method in different phases with a legitimate test datum?
What is the inﬂuence of using the PR method in different case studies?
What is the difference between multiple PR models and a single PR model applying in the neural networks?
What is the difference between the PR method and the random noise injection?
E XPERIMENT TO ANSWER Q UESTION #
The objective of performing these experiments is to demonstrate that PR augmented training method has more advantages than common training methods.
From Table 1, we produce four different results by applying the PR method in different phases.
These include (1) applying no PR method, denoted as non-PR (i.e. common training method), (2) applying PR method during the training phase, (3) testing phase (4) and both phases.
We analyze that applying PR method (either during the training phase or both phases) is not signiﬁcantly different with non-PR case in terms of the accuracy.
This means that neural networks trained with PR method show comparable performance to those trained without PR method.
From the results of “Testing Phase” in Table 1, it can be seen that neural networks trained without PR (i.e. non-PR) are not sufﬁciently robust when they are exposed to images perturbed by PR method.
In other words, we can use PR method as an attack technique to fool the trained neural networks.
The accuracy for the MNIST and Fashion MNIST datasets are greatly decreased in Table 1 could be caused by over-ﬁtting when a large number of epochs have passed.
However, our method can relieve the over-ﬁtting issue as shown in Table 1 when we apply
PR method in the training phase only.
The neural networks can classify clean images correctly after we train them with PR method.
We conjecture PR method has performed regularization while training the neural networks.
Common regularization methods (e.g. dropout, weight decay, etc.) usually are related with neural networks architecture, but our PR method is applied to the data themselves.
[Table]
4. E XPERIMENT TO ANSWER Q UESTION #
The goal of operating these experiments is to validate whether PR method can be effectively used as a defense technique against the state-of-the-art attack techniques.
We conduct ﬁve cases that we have discussed in Section 3.4 in this sub-section.
From Table 2, PR method can defend most attacks in the case A and D. One interesting observation that we have found in the case B is that the neural networks which have been trained with PR method during the training phase are robust to defend most attacks (except the L 2 -CW attack) even if we do not apply PR method during the testing phase.
This shows that our PR method boosts the robustness of the neural networks.
For the case C, the performance of the neural networks is signiﬁcantly degraded due to large increase of L p distance (i.e. the distance between the original image and the adversarial image).
As we know, the case C is not practical because the L p distance has to be as low as possible in order to create an adversarial example.
Although the case C is impractical, we still perform the case D to validate our PR method can increase the robustness of the neural network (except MNIST dataset with FGSM technique because of high distortion of the generated adversarial image as shown in Fig. 3).
We conjecture our method which can defend the attacks effectively because it has eliminated most adversarial pixels during the pre-processing phase.
Furthermore, we can see that our PR method performs better in the grayscale dataset from the comparison between CIFAR-10 and CIFAR-10 (grayscale) dataset.
[Table]
In addition, we compare the performance between a neural network trained with PR method (during the training phase) and a neural network trained without PR method under four different attacks, shown in Table 3.
Note that we do not apply PR method during testing phase for the neural network that has been trained with PR method (case B).
From Table 3, neural networks trained with PR method show higher performance than non-PR neural networks except in the normal case.
This result indicates our PR method can increase the robustness of the neural network.
4. E XPERIMENT TO ANSWER Q UESTION #
The target of implementing these experiments is to present the beneﬁt of using the multiple PR models rather than the single PR model.
As aforementioned, the case C is impractical since the case C will cause high L p distance.
Hence, we do not include case C (and D) in this sub-section.
From Table 4, the one with the multiple PR models outperforms the one with a single PR model.
In average of the accuracy, the multiple PR models produce 1.86% and 1.16% higher than the single
PR model for case A and B respectively.
This shows the multiple PR models produce a stronger defense than the single PR model.
We leave the experiments for the parameters tuning of multiple
PR models in the future.
[Table] [Table]
4. E XPERIMENT TO ANSWER Q UESTION #
The aim of conducting these experiments are to distinguish between PR model and random noise injection.
Note that the value of the random noise that we used in this sub-section is between -1.0 and 1.0 with the uniform distribution and we clip the value of the pixel between 0.0 and 1.0 (normalized pixel value).
We list several outputs with the use of the PR method and random noise injection in
Fig.
Besides that, we show the experiment results for the random noises injection with the legitimate data in Table 5.
We use a similar settings in Section 4.1 to only apply the random noises injection during the training phase, testing phase and both phases.
Comparing the results of the PR method (shown in Table 1) and those of the random noise injection (shown in Table 5), we can see that the PR method outperforms the random noise injection in “Training Phase” and “Both Phases”.
Although the random noise injection has high performance in fooling the trained neural networks (in the case when we apply the random noise injection during the testing phase only), the L 2 distance is larger than our method since the image generated with the random noise injection cannot be easily recognized by the human. (shown in Fig.
In summary, the PR method is different from the random noise injection in terms of the performance in maintaining the accuracy when the number of the epoch is increased.
Moreover, the PR method can maintain the newly generated image perceptible by the human.
[Table]
4. S UMMARY OF PR METHOD
From the experiment results
[Table]
we summarize the contribution of using the PR method as follows:
• The PR method relieves the over-ﬁtting issue by generating different possible output of the image.
(Q1) •
The PR method increases the robustness of the neural networks.(Q2) •
The defense level for the one with the multiple PR models is stronger than the one with the single PR model.
(Q3)
• The PR model has higher performance than the random noise injection.
(Q4)
C ONCLUSION
In this study
[Table]
we propose a novel method, namely Pixel Redrawn method which regenerates the image to all possible forms without compromising human perception.
We address four questions in our experiments: Q1 What is the inﬂuence of applying the PR method in different phases with a legitimate test datum?,
Q2 What is the inﬂuence of using the PR method in different case studies?,
Q3 What is the difference between multiple PR models and a single PR model applying in the neural networks?, and Q4 What is the difference between the PR method and the random noise injection?
From the experimental results, our method shows that it can prevent the over-ﬁtting problem while maintaining the performance of the neural network, it also improves the robustness of the neural network.
Furthermore, our method is more reliable than using some random noises.
A A PPENDIX A. E XPERIMENTS TO ANSWER Q UESTION #
In this appendix, we provide Table 6, which is the extended version of Table 2 in Section 4.2.
Note that more results with 50 and 500 epochs are added.
We also provide Table 7 and 8 with k = 4 and k = 10 respectively.
The purpose of the experiments is to analyze the inﬂuence of the k value (the number of colors) to the performance of the neural network.
From Table 6, 7 and 8, we observe that the bigger the k , the higher the accuracy when we test with the legitimate example, but the lower the accuracy when we test with the adversarial examples.
In other words, we have to deal with a trade-off between legitimate examples and adversarial examples.
Although we believe that multiple PR models could increase the accuracy for adversarial examples while using a large value of k , we leave these experiments in the future.
A. E XPERIMENTS TO ANSWER Q UESTION #
In this appendix, we show Table 10 as the extended version of Table 4 in Section 4.3 with the results of the multiple PR models and the single PR model with two epochs (i.e. 500 and 1,000 epochs).
In
Table 10, it can be seen that the multiple PR models outperforms the single PR model, because the multiple PR models provide more new images to train as was discussed in Section 2.5.
A. E XPERIMENTS TO ANSWER Q UESTION #
In this appendix, we show the comparison results between PR method (case A) and adversarial training with 1,000 epochs for several datasets in Table 11.
We apply MIM attack technique during the adversarial training.
In Table 11, it can be seen that our method outperforms adversarial training in most cases.
[Table]
BIM, (cid:15) = 0 . 0.
MIM, (cid:15) = 0 . 0.
L 2 -CW 0.
[Table]
FGSM, (cid:15) =
[Table]
BIM, (cid:15) =
[Table]
MIM, (cid:15) =
[Table] [Table]
[Table]
FashionMNIST
[Table]
BIM, (cid:15) = 0 . 0.
MIM, (cid:15) = 0 . 0.
L 2 -CW 0.
CIFAR
FGSM, (cid:15) = 0 . 0.
BIM, (cid:15) = 0 . 0.
MIM, (cid:15) = 0 . 0.
[Table] [Table]
FashionMNIST
[Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
MIM
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table]
BIM
[Table] [Table]
[Table] [Table]
[Table] [Table]
MIM
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]