Does Saliency-Based Training bring Robustness for Deep Neural Networks
  in Image Classification?
Deep Neural Networks are powerful tools to understand complex patterns and
making decisions. However, their black-box nature impedes a complete
understanding of their inner workings. While online saliency-guided training
methods try to highlight the prominent features in the model's output to
alleviate this problem, it is still ambiguous if the visually explainable
features align with robustness of the model against adversarial examples. In
this paper, we investigate the saliency trained model's vulnerability to
adversarial examples methods. Models are trained using an online
saliency-guided training method and evaluated against popular algorithms of
adversarial examples. We quantify the robustness and conclude that despite the
well-explained visualizations in the model's output, the salient models suffer
from the lower performance against adversarial examples attacks.
Ali Karkehabadi
# Does Saliency-Based Training bring Robustness for Deep Neural Networks in Image Classification?

###### Abstract

Deep Neural Networks are powerful tools to understand complex patterns and making decisions. However, their black-box nature impedes a complete understanding of their inner workings. While online saliency-guided training methods try to highlight the prominent features in the model's output to alleviate this problem, it is still ambiguous if the visually explainable features align with robustness of the model against adversarial examples. In this paper, we investigate the saliency trained model's vulnerability to adversarial examples methods. Models are trained using an online saliency-guided training method and evaluated against popular algorithms of adversarial examples. We quantify the robustness and conclude that despite the well-explained visualizations in the model's output, the salient models suffer from the lower performance against adversarial examples attacks.

## 1 Introduction

### Saliency Guided Training

Deep Neural Networks have gained immense attention from researchers in different complicated applications LeCun et al. (2015); Farabet et al. (2012); Mikolov et al. (2010); Mittal and Hasija (2020); Brants et al. (2007). However, their black-box nature hampers their application in critical domains. To this end, providing explanations of the inner working process in the models has been investigated by researchers Khakzar et al. (2022). Some works investigate the post-hoc explanations from the model by either evaluating backpropagated gradients Selvaraju et al. (2017); Omeiza et al. (2019) or by evaluating the model's performance in the presence of a perturbation occurring in an area of the input Fong et al. (2019); Fong and Vedaldi (2017); Samek et al. (2016). There are some works trying to shallow down the Deep Neural Network architecture to reduce the ambiguity of the modelFrossi and Hinton (2017); Wu et al. (2018). Others try to include the saliency in the training process.Ross et al. (2017) uses annotations on the irrelevant parts of input and penalizes the model for negative gradients to teach the model learn salient features. The authors add a regularization term that jointly optimizes the accuracy and penalization of negative gradients. Ghaeini et al. (2019) extends the work by involving intermediate layers, too. They teach the model to learn human-understandable features by providing ground truth masks for the positive gradient as explanations. The method trains the model with training data, labels and ground truth explanation masks. Ismail et al. (2021) improves the model's salient features by removing input pixels related to lower gradient values from backpropagation. Input areas with lower gradient impact are masked with random values. Authors add Kullback-Leibler (KL) divergence as a similarity metric in the loss function. The model is enforced to output similar distribution for both the original image and the masked one. The strategy helps the model to focus on the salient features which are considered to be more interpretable and be negligent to low gradient values.
### Adversarial Examples

Although Deep Neural Networks have achieved state of the art performance in different domains, they might be vulnerable to small hardly perceptible artifact manipulation in the input. Szegedy et al. (2013) Revealed that nuisance perturbations in the input images cause a misclassification by the model. Since this early study, others started developing different approaches to add a small perturbation toward the input to fool the model. Goodfellow et al. (2014) Introduced Fast Gradient Sign Method (FGSM). The method adds a small perturbation to all the input image pixels in the direction of the gradient. This simple but effective method built the basic block for more sophisticated attacks. Kurakin et al. (2018) and Madry et al. (2017) developed the algorithm in an iterative approach and introduced Basic Iterative Method (BIM) and Projected Gradient Descent (PGD). These approaches put a constraint on the perturbation to ensure that it is small enough to be imperceptible. Dong et al. (2018) considered generating strong adversarial examples using the previous momentum of gradients iteratively.

Adversarial examples initially intended to attach the models for malfunction. Meanwhile, they are considered as the evaluation metrics for the model's performance against manipulated inputs.

Inspired by Saliency guided training procedures which makes the model explicitly show important features and adversarial example progresses, this paper investigates the effect of saliency-based training on the adversarial robustness of Deep Neural Networks. Although similar works like Etmann et al. (2019) show that adversarial training for the model's robustness leads to improvement in saliency maps, we are unaware of research investigating the effect of saliency, training on adversarial robustness. This paper follows several experiments and gives insights into the connection between saliency training and robustness.

## 2 Methodology

Our objective is to establish a fair comparison between regular and saliency-guided models against different adversarial attacks. Models are trained from scratch for classification task. Saliency-guided models are trained following Ismail et al. (2021). To quantify the robustness, we considered white-box attacks. White-box adversarial examples are generated with full awareness of the model's weights. We evaluated various perturbation-based algorithms following Rauber et al. (2017). We briefly review the adversarial attack algorithms in this section and discuss the results in the next sections.

```
1:Initialize\(f_{\theta_{0}}\)
2:for\(i=1\) to \(N_{epochs}\)do
3: Indexes = Sort(\(\nabla_{x}f_{\theta_{i}}\))
4: Masking(\(X(Indexes)\))
5: Calculating the loss: \(L_{i}=L(f_{\theta}(X_{i}),y_{i})+\lambda D_{KL}(f_{\theta}(X_{i})|f_{\theta}( \widetilde{X}_{i}))\)
6: Updating the model's weights
7:endfor
8:end
```

**Algorithm 1** Saliency Training

### Saliency Guided Training

Following Ismail et al. (2021), the saliency-guided training model is trained by adding a regularization term in the cost function. In each iteration, input images are fed to the model, gradients are calculated and sorted by their magnitude. \(K\) is defined as a parameter which determines the number of the lower gradients being replaced. By attributing the gradient values to the input, related pixels are masked. Algorithm 1 shows the training procedure. Masking values are randomly selected from the uniform distribution of the original image pixel value range. To make the model learn salient features, the model's weights are updated to output same output distribution for the original and masked input. Kullback-Leibler (KL) divergence regularization term in Eq.1 guarantees this.

\[\sum_{i=1}^{n}\left[L(f_{\theta}(X_{i}),y_{i})+\lambda D_{KL}(f_{\theta}(X_{i })|f_{\theta}(\widetilde{X}_{i}))\right] \tag{1}\]

where \(X_{i}\) is input data, \(\widetilde{X}_{i}\) is masked input and \(\theta\) is model's parameters. Hyperparameter \(\lambda\) works as a tradeoff between loss function terms.
### Fast Gradient Sign Method

FGSM Goodfellow et al. (2014) is a white-box method that tries to manipulate the whole input data based on the model's weights in order to lead the model to an incorrect prediction. The perturbation occurs in the direction of the sign of the gradient. It is a fast one-step gradient with a fixed step size. Eq.2 shows the update algorithm where \(\epsilon\) is the amount of perturbation and \(y_{true}\) is the correct label for the input \(x\).

\[x^{\rm adv}=x+\epsilon\cdot\mathrm{sign}(\nabla_{x}J(x,y_{true})) \tag{2}\]

### Basic Iterative Method

BIM Kurakin et al. (2018) extends FGSM by applying a small amount of perturbation in each iteration. After each step, the generated input is clipped so that the final results would be in \(\epsilon\)-neighbourhood of the main input:

\[x_{0}^{adv}=x,x_{n+1}^{adv}=Clip_{x,\epsilon}(x_{N}^{adv}+\alpha sign(\nabla_{ x}J(x_{N}^{adv},y_{true}))) \tag{3}\]

### Projected Gradient Descent

Similar to BIM, PGD Madry et al. (2017) generates the adversarial examples in an iterative way. In each stage, the input is manipulated by solving a constrained optimization problem. The predefined amount of constraint keeps the content as the original input so that the generated example seems imperceptibly different to human eyes. The PGD is different from BIM as the initialization is set randomly.

### Momentum Iterative Method

MIM Madry et al. (2017) iterates over the cumulative direction of previous gradients to perturb the input.

\[g_{(N+1)}=\mu g_{N}+\frac{\nabla_{x}L(f(x_{N}^{adv},\theta^{*}),y)}{\|\nabla_{ x}L(f(x_{N}^{adv},\theta^{*}),y)\|_{2}},x_{(N+1)}^{adv}=x_{N}^{adv}+\alpha \cdot sign(g_{(N+1)}) \tag{4}\]

## 3 Implementation Details

### Datasets

#### Mnist

The dataset LeCun et al. (2010) includes 10 classes of handwritten digits containing 70000 grayscale images with the \(28*28\) pixel size. We split the dataset into 60000 images for training and 10000 for test set.

#### Cifar-10

Including 60000 low-resolution RGB images. The dataset contains 10 classes consisting of Airplanes, Cars, Birds, Cats, Deer, Dogs, Frogs, Horses, Ships, and trucks. Training and test set include 50000 and 10000 images respectively.

#### Model Architecture

We focused on Convolution-based architectures for implementation. Our Architecture follows Ismail et al. (2021) for the Saliency-guided training model. For MNIST dataset, we employed a two-layer CNN network with kernel size 3 and stride of 1. Two Fully-Connected layers were followed by the network. Two drop-out layers also were used with \(p=0.25\) and \(p=0.5\).

For CIFAR-10, following Ismail et al. (2021), we used ResNet18 (Pretrained on ImageNet) He et al. (2016) and 10 neuron classifier as the output. We trained our models using single NVIDIA A100 GPU. The models were trained for 100 epochs with the batch size 256. Models used Adadelta Zeiler (2012) as the optimizer with learning rate \(0.1\).

During the training and within each epoch, low gradient values are replaced with random values. The values are in the range of the remaining pixels for the image. Gradient values are calculated using Captum library Kokhlikyan et al. (2020). A fixed amount of \(50\%\) of lower gradient values are removed.

accuracy and for a fair comparison, we employed the same architecture for regular training.
#### Robustness

For robustness evaluation we used Foolbox Rauber et al. (2017) library for adversarial attack algorithms. We evaluated the model's test accuracy for different degrees of perturbation.

## 4 Results and Discussions

Our purpose is to quantify the connections between robustness and saliency training approach. To this end, we trained the models following saliency-guided training Ismail et al. (2021). Also, we train the same architecture without guided training as a baseline for comparison. Afterward, we evaluate the classification accuracy of the trained models against adversarial examples. Results for MNIST and CIFAR-10 are shown in 1 and 2 respectively.

### Conclusion

The interpretability of Deep Learning models is of high importance based on the application. As the topic grows popular among researchers, we investigate a different aspect of salient training. Despite the fact that high values of gradient might help for better visual interpretability, our results show that it might compromise vulnerability against attacks. Through visual observations (Fig.3) from the models with the salient approach in their learning process, it could be figured out that by highlighting high-value gradients and their pertinent pixels that are considered as the main object, the main object is the center of attention for adversarial examples. According to the adversarial examples formula which work in the direction of gradient, results seems to be grounded. This gives way to adversarial methods to affect the

\begin{table}
\begin{tabular}{l c c c c} \hline \hline Dataset & \# Test & \# Classes & Accuracy & SAL-Accuracy \\ \hline MNIST & 10000 & 10 & 99.3\% & 98.8\% \\ CIFAR-10 & 10000 & 10 & 82.8\% & 82.2\% \\ \hline \hline \end{tabular}
\end{table}
Table 1: Traditional and Saliency Model Training Accuracy

Figure 1: Saliency guided trained and regular model performance against attacks over MNIST dataset for different amount of perturbation. a. FGSM attack b. PGD attack c. BIM attack

Figure 2: Saliency guided trained and regular model performance against attacks over CIFAR10 dataset for different amount of perturbation. a. FGSM attack b. PGD attack c. BIM attack
model's performance. Our work encourages and attracts the attention of the researchers to consider both aspects of saliency and robustness.
