Exploring Adversarial Attacks on Neural Networks: An Explainable
  Approach
Deep Learning (DL) is being applied in various domains, especially in
safety-critical applications such as autonomous driving. Consequently, it is of
great significance to ensure the robustness of these methods and thus
counteract uncertain behaviors caused by adversarial attacks. In this paper, we
use gradient heatmaps to analyze the response characteristics of the VGG-16
model when the input images are mixed with adversarial noise and statistically
similar Gaussian random noise. In particular, we compare the network response
layer by layer to determine where errors occurred. Several interesting findings
are derived. First, compared to Gaussian random noise, intentionally generated
adversarial noise causes severe behavior deviation by distracting the area of
concentration in the networks. Second, in many cases, adversarial examples only
need to compromise a few intermediate blocks to mislead the final decision.
Third, our experiments revealed that specific blocks are more vulnerable and
easier to exploit by adversarial examples. Finally, we demonstrate that the
layers $Block4\_conv1$ and $Block5\_cov1$ of the VGG-16 model are more
susceptible to adversarial attacks. Our work could provide valuable insights
into developing more reliable Deep Neural Network (DNN) models.
Justus Renkhoff, Wenkai Tan, Alvaro Velasquez, illiam Yichen Wang, Yongxin Liu, Jian Wang, Shuteng Niu, Lejla Begic Fazlic, Guido Dartmann, Houbing Song
# Exploring Adversarial Attacks on Neural Networks: An Explainable Approach

###### Abstract

Deep Learning (DL) is being applied in various domains, especially in safety-critical applications such as autonomous driving. Consequently, it is of great significance to ensure the robustness of these methods and thus counteract uncertain behaviors caused by adversarial attacks. In this paper, we use gradient heatmaps to analyze the response characteristics of the VGG-16 model when the input images are mixed with adversarial noise and statistically similar Gaussian random noise. In particular, we compare the network response layer by layer to determine where errors occurred. Several interesting findings are derived. First, compared to Gaussian random noise, intentionally generated adversarial noise causes severe behavior deviation by distracting the area of concentration in the networks. Second, in many cases, adversarial examples only need to compromise a few intermediate blocks to mislead the final decision. Third, our experiments revealed that specific blocks are more vulnerable and easier to exploit by adversarial examples. Finally, we demonstrate that the layers \(Block\_conv1\) and \(Block\_cov1\) of the VGG-16 model are more susceptible to adversarial attacks. Our work could potentially provide useful insights into developing more reliable Deep Neural Network (DNN) models.

## I Introduction

Artificial intelligence (AI) and deep learning (DL) provide unlimited possibilities for addressing various engineering and scientific problems. However, the reliability and robustness of Deep Neural Networks (DNNs) has caused many concerns; for example, some researchers revealed that DNNs, such as the VGG-16 model [1], can be misled by intentionally mutated images that are imperceptible to humans [2, 3, 4]. In these scenarios, the mutated pixels have pseudo-random characteristics and thus raise concerns about the uncertainty and trustworthiness of DNNs under the natural Gaussian noise of their operational environments [5, 6].

For mitigation, on the one hand, some solutions are proposed to increase the robustness of DNNs by augmenting their training with perturbed samples or introducing a robust loss term [7, 8, 9]. These approaches encourage DNNs to treat a slightly perturbed image as its origin. In this context, finding and incrementally training DNNs with adversarial examples is analogous to fuzzy testing. Some representative frameworks are proposed, such as DLFuzz [10], DeepXplore [2], DeepHunter [11], and TensorFlow12.

Footnote 1: We use the same notation as in [11], but we use the same notation as in [11].

One common feature of these adversarial example-enabled neural network fuzzy testing frameworks is that they not only discover adversarial examples but also try to maximize the activation rates of neurons, a.k.a. neuron coverage [13, 14]. Neuron coverage describes how many neurons are activated during a prediction. DLFuzz [10] adapts this concept from DeepXplore [2] and tries to optimize this metric by generating adversarial examples and maximizing the prediction difference between the original and the adversarial images. Higher neuron coverage usually contributes positively to the robustness of DNNs.

However, training DNNs on perturbed samples incrementally is computationally expensive and can reduce classification accuracy [15]. Moreover, it is difficult to find a balance between accuracy and adversarial robustness. Defending existing DNNs against adversarial examples is preferable. Defense-GAN [16] trains a defensive generative adversary network (GAN) on natural inputs. A noticeable behavior deviation can be detected when adversarial examples are fed into the defensive GAN. Instead of modeling the inputs directly, I-Defender [17] models the output distributions of fully connected hidden layers on each class. Then it uses statistical testing to reject adversarial examples. Adversarial perturbations can be treated as additive noise. Therefore, similar approaches, such as denoising autoencoders, can be used to purify the input of DNNs [18, 19, 20, 21].

Most of the current efforts still regard DNNs as black-box models and have not yet analyzed the effect of adversarial attacks in an explainable way. In this paper, we use images from the ImageNet database [22] and then manipulate them with DLFuzz [10], which generates adversarial examples based on given seed images and tries to activate as many neurons as possible simultaneously. Grad-CAM [23] heatmaps are generated to make the decision-making procedure explainable. Wrongly classified mutated images are analyzed and compared to their
origin to find out why and in which layer of the behavior deviations occur. We compare the response characteristics of the VGG-16 model using Grad-CAM when the input images are mixed with adversarial and statistically similar Gaussian noise. Our findings are as follows.

* Both random noise and adversarial noise cause behavioral deviations of intermediate layers. However, adversarial noise causes more behavioral deviations by distracting the area of focus in the intermediate layers.
* There are certain blocks that are more vulnerable and more easily exploited by adversarial examples. In particular, we demonstrate that the layers \(Block4\_conv1\) and \(Block5\_cov1\) of the VGG-16 model are more susceptible to adversarial attacks.
* We show that a neural network model can be misled by compromising only a few blocks.

The remainder of this paper is organized as follows: A literature review of related work is presented in Section II. We present the methodology in Section III. The evaluation and discussion are presented in Section IV with the conclusions in Section VI.

## II Related Work

Current efforts aim at increasing the robustness of DNNs against adversarial attacks. Accordingly, current research addresses approaches to make the decision-making of DNNs more transparent [24][25][26], and to find vulnerabilities in model architectures [27][28]. Since this research is utilized and closely related to our approach, we discuss these efforts in the following.

_Adversarial Attacks_: An adversarial example is generated by introducing small and imperceptible perturbations to a given seed image to cause misclassifications. There are several procedures, such as FGSM [29], to generate adversarial examples. In general, an adversary attacker has to know the parameters of the target neural classifier and then solve an optimization problem that the perturbations should maximize the classification loss and minimize the difference between perturbed and original image. Defending DNNs against adversarial examples can increase the robustness of the model.

_Visual Explanations_: Methods like Gradient-weighted Class Activation Mapping (Grad-CAM) [25] and Local Interpretable Model-Agnostic Explanations (LIME) [26] aim to improve the interpretability of DNNs. They have the ability to explain the prediction of black-box models, and can therefore improve their trustworthiness. Grad-CAM calculates a heatmap that highlights different areas of an image in different colors. These colors visualize how much an area positively contributes to a certain prediction. LIME highlights pixels that contribute positively or negatively on the basis of a threshold. These pixels can be represented in different colors, as in Grad-CAM. With Grad-CAM, it is possible to identify not only which areas contribute positively and negatively to a certain prediction, but also how much an area influences a decision [30]. There are numerous efforts that use or improve these methods to increase confidence in machine learning models [31][32][33].

## III Methodology

### _Problem Formulation_

To make DNNs as robust as possible to adversarial attacks, we must understand how adversarial examples cause misclassifications. For this reason, the classification process is analyzed layer by layer to find sections of an exemplary selected DNN that are particularly vulnerable to such attacks. Herewith, we want to present a procedure to analyze any DNN, making it possible to find vulnerabilities in the fundamental network architecture to be able to counteract these in the future. A brief workflow of this paper is given in Figure 1.

In general, original samples (a.k.a. natural images), adversarial examples, and noisy samples are then analyzed using Grad-CAM. A heatmap is generated for each layer of the target VGG-16 model showing what the focus point of the DNN in the corresponding layer is. Then, the cosine similarity is calculated between the heatmaps of the adversarial examples and those of the original images for every layer. By locating layers where the similarity between the adversarial and the original samples is particularly low, we can determine which layers react strongly to the perturbations.

### _Data Preparation_

We used randomly selected images as seeds from the ImageNet dataset, and we derive their adversarial perturbations (a.k.a. adversarial noise), denoted as:

\[\mathbf{N}_{a}=\text{ADV}(\mathbf{S},\mathbf{\varepsilon}) \tag{1}\]

where \(\text{ADV}(\cdot)\) is the adversarial perturbation function, \(\mathbf{\varepsilon}\) is the strength of the perturbation, and \(\mathbf{S}\) denotes a seed image. In this work, DLFuzz is configured to generate adversarial noise and maximize neuron coverage at the same time. We generate the same amount of Gaussian noise \(\mathbf{N}_{g}\), defined as random perturbations, with statistical properties similar to the adversarial perturbations. Accordingly, we use the expected value, standard deviation and shape of \(\mathbf{N}_{a}\) to generate \(\mathbf{N}_{g}\). We define the distribution as:

\[\mathcal{N}(\mu_{a},\Sigma_{a}) \tag{2}\]

where \(\mathcal{N}(\cdot)\) denotes a normal distribution, \(\mu_{a}\) denotes the expected value, and \(\Sigma_{a}\) denotes the standard deviation. We

Fig. 1: Exploring neural network response against adversarial perturbations and Gaussian noise.
let \(\mu_{a}=\overline{\mathbf{N}_{a}}\) and \(\Sigma_{a}=\sigma(\mathbf{N}_{a})\). Based on this distribution, we generate random noise \(\mathbf{N}_{g}\) represented as a matrix with the same shape as \(\mathbf{N}_{a}\). For more details, please refer to our implementation in GitHub1. In this way, the augmented input \(\mathbf{I}\) to the DNN becomes:

Footnote 1: [https://github.com/JustusRen/Exploring-Adversarial-Attacks-on-Neural-Networks](https://github.com/JustusRen/Exploring-Adversarial-Attacks-on-Neural-Networks)

\[\mathbf{I}=\{\mathbf{S},\mathbf{S}+\mathbf{N}_{a},\mathbf{S}+\mathbf{N}_{g}\} \tag{3}\]

where \(\mathbf{S}+\mathbf{N}_{a}\) and \(\mathbf{S}+\mathbf{N}_{g}\) are adversarial examples and the noisy version of the seed image.

### _Network Behavior Deviation Detection_

For a given convolutional layer \(l\), its response to an input image, e.g., a seed image, can be visualized using its grad-CAM heatmap, defined as:

\[\mathbf{H}(\mathbf{S})=R\left[sign\left(\frac{\mathbf{J}(\mathbf{S})}{\partial \theta_{\mathbf{I}}}\right)\right] \tag{4}\]

where \(\mathbf{J}(\mathbf{S})\) denotes the classification loss given \(S\) and \(\theta_{\mathbf{I}}\) denotes the parameters of layer \(l\). The function \(R(\cdot)\) denotes the operation that reshapes and interpolates the derived gradients to the same dimension and size as \(\mathbf{S}\). The Grad-CAM heatmap displays the focal areas of \(l\) in \(\mathbf{S}\). Therefore, the degree or level of behavioral deviations of the heatmap under the perturbed sample and the natural image can be used to quantify whether it is compromised. Hereby, we use cosine similarity to calculate the degree of behavioral deviations as:

\[\mathbf{G}[\mathbf{S_{1}},\mathbf{S_{2}}]=\frac{vec(\mathbf{H}(\mathbf{S_{1} }))\cdot vec(\mathbf{H}(\mathbf{S_{2}}))}{\|vec(\mathbf{H}(\mathbf{S_{1}}))\| \cdot\|vec(\mathbf{H}(\mathbf{S_{2}}))\|} \tag{5}\]

where \(\mathbf{H}(\mathbf{S_{1}})\) and \(\mathbf{H}(\mathbf{S_{2}})\) denote Grad-CAM heatmaps of different images. These are vectorized and normalized for the similarity calculation. For a specific layer and a seed image \(\mathbf{S}\), we calculate and compare two degrees of behavioral deviation:

\[\mathbf{D}_{a}=\mathbf{G}[\mathbf{S},\mathbf{S}+\mathbf{N}_{a}] \tag{6}\]

\[\mathbf{D}_{g}=\mathbf{G}[\mathbf{S},\mathbf{S}+\mathbf{N}_{g}] \tag{7}\]

Our observations revealed that both Gaussian noise and adversarial perturbations can cause behavioral deviations. For each layer, we used the median value of its degree of behavioral deviation under Gaussian noise as the threshold to quantify whether it is compromised, i.e. whether its behavior deviates more severely than when it is under the same amount and strength of Gaussian noise.

### _DLFuzz for Adversarial Example Generation_

We use DLFuzz [10] to calculate perturbations and applied to images from the ImageNet [34] data set. The procedure of deriving additive perturbations is regarded as an optimization problem as:

\[\underset{\mathbf{N}_{a},\ ||\mathbf{N}_{a}||\leq\delta}{\text{argmax}}\left[ \sum_{i=1}^{K}c_{i}-c+4\sum_{i=0}^{m}n_{i}\right] \tag{8}\]

where \(\delta\) restricts the magnitude of the adversarial perturbation, \(c\) is the prediction on a given seed image, \(c_{i}\) is one of the top \(K\) candidate predictions, \(n_{i}\) is one of the activation values in the \(m\) selected neurons, and \(\lambda\) is a constant to balance between activating more neurons and obtaining adversarial examples.

Mathematically, DLFuzz manipulates the perturbations to mislead a tested network to make wrong predictions and simultaneously activate the selected neurons. By maximizing neuron coverage, DLFuzz ensures that adversarial examples are generated more efficiently during a test. Based on the assumption that this will trigger more logic in the network and thus provoke and detect more erroneous behavior [2], the underlying DNN we selected is the VGG-16 [1] model pre-trained on the ImageNet dataset.

After obtaining an effective adversarial perturbation for each seed, we amplify the perturbations with a total of five different ratios, defined as the perturbation strength. These are 25%, 50%, 100%, 200% and 400%.

## IV Evaluation and Discussion

In this section, we evaluate the behavior deviation of a pre-trained VGG-16 network under adversarial examples and Gaussian noise.

### _Seed Selection_

The ImageNet dataset contains more than 10 million images in 1,000 categories. We randomly pick five images from each category to derive their adversarial examples. Unfortunately, not all images can find their corresponding adversarial examples within the pre-defined magnitude of perturbation. Ultimately, we derived at least one adversarial example from 48% of the randomly collected images.

### _Neuron Coverage under different attacks_

Figure 1(a) shows the progression of the neuron coverage of the model using images with adversarial noise and random noise. It is noticeable that the neuron coverage increases slightly faster using adversarial perturbations. However, DLFuzz can also increase neuron coverage using random perturbations. Furthermore, Figure 1(b) shows how the neuron coverage increases when different perturbations strengths are applied to the seed images. In general, the strength of the perturbation has a slight effect on the neuron coverage. The less severe the perturbation, the slower the neuron coverage increases.

### _Network Vulnerability Analysis_

We used the Grad-CAM heatmaps of each layer under natural images as references and used cosine similarities to measure their behavior deviations under different attacks as shown in Figure 3. More specific statistical analysis is presented in Figure 3(a), where the Grad-CAM responses of the neural network under adversarial examples are severely deviated. More specific statistical analysis is presented in Figure 3(a), where the Grad-CAM responses of the neural network under adversarial examples are severely deviated. Under
adversarial examples, each layer's heatmap cosine similarities to the natural image have lower mean values and greater variances in comparison with the similarities under noisy images.

In particular, the two layers, Block4_Conv1 and Block5_Conv1, are considered to be easier to compromise because their response deviates more significantly under adversarial noise, showing a lower average cosine similarity than when it receives images with pure Gaussian noise. Interestingly, Gaussian noise also causes network behaviors to deviate from those when the network receives only clear images. As shown in Figure (b)b, although we observe lower cosine similarities, the response deviation is not as significant as when the network is under adversarial examples.

### _Behavior Drift Under Different Attack Strengths_

As we mentioned, Gaussian noise and adversarial perturbations can cause deviations in network behavior. Adversarial perturbations can drift the network behavior more and play a significant role in adversarial attacks. As given in Equation 2, the Gaussian random perturbations will have statistical properties consistent with adversarial perturbations.

According to Figure (a)a and (b)b, the comparison of cosine similarities in grad-CAM heatmaps indicates that adversarial inputs have a lower overall value (a.k.a., more severe behavior deviations) than noisy inputs at all attack levels. When we adjust the attack strength, the cosine similarities on adversarial inputs decrease more. The Grad-CAM heatmap cosine similarities decrease more significantly, indicating more severe behavioral deviations as determined by a smaller cosine similarity, when adversarial perturbations are amplified 2 and 4 times. Comparably, although the network's averaged behavior also deviates under Gaussian noisy images, the averaged magnitude of deviation is not as significant as under adversarial perturbations. Although it is generally believed that a stronger

Fig. 3: Gradient CAMs of VGG-16 under different inputs. Red and green rectangles highlight the convolutional layers that have significant behavior drifts.

Fig. 2: Comparison of neuron coverage optimization with random perturbations, targeted perturbations and different perturbation strengths
adversarial attack strength can cause the behavior of the neural network to deviate further, our experiments show that the behavioral deviation is still significant when the attack strength is reduced to 0.25, for which the three curves when the attack strength are 0.25, 2 and 4 are very similar. Interestingly, behavioral deviations under attack strength 0.5 and 1 are almost identical.

In general, more significant behavioral deviations can be observed in deeper layers of the network, as shown in Figures 4(a) and 4(b). However, we do notice some fluctuations, which indicates that there are some specific layers that are more vulnerable and easier to compromise.

### _Distributions on the number of compromised layers_

We also discover that the VGG-16 network can be misled by compromising only a few intermediate layers. We analyze the probability of compromise for each network layer and derive Figure 6. The statistical distribution of the number of compromised layers with all adversarial examples is shown in Figure 7.

From the previous discussions, perturbations driven by Gaussian noise can cause behavior drift but not necessarily mislead the classifier. As mentioned in Section III-C, we define a threshold for each convolutional layer in different perturbation levels, and this threshold equals the median value of the behavior deviations when this layer processes the input image with pure Gaussian noise. Intuitively, a layer is called compromised when its behavior under adversarial examples deviates further than it should be under the same input mixed

Fig. 4: Comparison of behavioral deviations under: (a) adversarial examples and (b) random noise for the VGG-16 convolutional layers (x-axis 1-1 represents the Block1_Conv1 layer in VGG-16).

Fig. 5: Comparison of average behavioral deviation on: (a) adversarial examples and (b) images with Gaussian noise with different attack strength (x-axis 1-1 represents the Block1_Conv1 layer in VGG-16).

Fig. 6: Compromise probability of convolutional layers in the VGG-16 network.
with Gaussian noise.

As shown in Figure 6, the adversarial examples with the lowest attack strength have approximately 40% of the chance to compromise any layer. This probability increases significantly and reaches 80% when we increase the attack strength to be greater than 2 or less than 0.25.

In Figure 7, we count the number of convolutional layers that have been compromised for all adversarial examples. We discover that there are some ultimate adversarial examples that can compromise all convolutional layers in the VGG-16 network. This chance of getting the ultimate adversarial examples increases when the attack strength is greater than 2 or less than 0.25. In addition, adversarial samples exist that can cause misclassification by compromising zero or only a small number of layers.

## V Conclusion

In this work, we generate adversarial examples using DL-Fuzz. Through Grad-CAM, we were able to analyze the decision-making procedure of the VGG-16 network layer by layer. In doing so, we were able to show that compared to Gaussian random noise, intentionally generated adversarial perturbations cause more severe behavioral deviations. Furthermore, we were able to show that in many cases, only a few intermediate blocks of a DNN need to be compromised in order to manipulate the final decision. Finally, we demonstrate that, in particular, the layers \(Block4\_conv1\) and \(Block5\_cov1\) of the VGG-16 model are more susceptible to adversarial attacks.

## VI Future Work

Utilizing our proposed approach, it is possible to find vulnerable layers in a DNN model. In future work, we want to explore the use of a zero-bias layer [35] to create more robust DNNs. In addition, it would be interesting to investigate how the focal point changes during the decision-making process of the DNN, and to what extent this correlates with the deliberate perturbations.

## Acknowledgment

This research was supported in part by the Air Force Research Laboratory Information Directorate, through the Air Force Office of Scientific Research Summer Faculty Fellowship Program(r), Contract Numbers FA8750-15-3-6003, FA9550-15-0001 and FA9550-20-F-0005. This research was also partially supported by the National Science Foundation under Grant No. 2150213.
