One-shot Neural Backdoor Erasing via Adversarial Weight Masking
Abstract
Recent studies show that despite achieving high accuracy on a number of realworld applications, deep neural networks (DNNs) can be backdoored: by injecting triggered data samples into the training dataset, the adversary can mislead the trained model into classifying any test data to the target class as long as the trigger pattern is presented.
Various methods have been proposed to nullify such backdoor threats.
Notably, a line of research aims to purify the potentially compromised model.
However, one major limitation of this line of work is the requirement to access sufficient original training data: the purifying performance is much worse when the available training data is limited.
In this work, we propose Adversarial
Weight Masking (AWM), a novel method capable of erasing the neural backdoors even in the one-shot setting.
The key idea behind our method is to formulate this into a min-max optimization problem: first, adversarially recover the trigger patterns and then (soft) mask the network weights that are sensitive to the recovered patterns.
Comprehensive evaluations of several benchmark datasets suggest that
AWM can largely improve the purifying effects over other state-of-the-art methods on various available training dataset sizes.
Introduction
Deep neural networks (DNNs) have been widely applied in a variety of critical applications, such as image classification [17], object detection [47, 62] , natural language processing [9] and speech recognition [19], with tremendous success.
The training of modern DNN models usually relies on large amount of training data and computation, therefore, it is common to collect data over the
Internet or directly use pretrained models from third-party platforms.
However, this also gives room for potential training-time attacks [42, 11, 22, 38, 40].
Particularly, backdoor attack [15, 32, 6, 42, 1, 33, 37, 44, 30] is among one of the biggest threats to the safety of the current DNN models: the adversary could inject triggered data samples into the training dataset and cause the learned DNN model to misclassify any test data to the target class as long as the trigger pattern is presented.
In the meantime, the model still enjoy decent performances on clean tasks thus the backdoors can be hard to notice.
Recent advanced backdoor attacks also adopt invisible [27], or even sample-specific [29] triggers to make it even stealthier.
Facing the immediate threat from backdoor adversaries, many backdoor defense or detection methods [31, 35, 16, 51, 57, 59] have been proposed.
Particularly, we focus on a line of research which aims to purifying the potentially compromised model without any access to the model’s training process.
This is actually a quite realistic setting as the large-scale machine learning model nowadays [9, 2] can hardly be trained by individuals.
Earlier works in this line usually purify the backdoored model via model fine-tuning [53, 7] or distillation [28, 14].
The problem is fine-tuning and distillation procedure can still preserve certain information on the backdoor triggers and thus it is hard to completely remove the backdoor.
Moreover, since it is hard to for one to access the entire training data, longer time of fine-tuning of a small subset of data usually leads to overfitting and deteriorated model performances on clean tasks.
In order to remove the backdoor in a more robust way, recent researches focus on removing the backdoor with adversarial perturbations [56, 59].
Particularly, [56] aims to extract sensitive neurons (by adversarial perturbations) that are highly related to the embedded triggers and prune them out.
However, one major limitation is that it still requires to access sufficient original training data in order to accurately locate those sensitive neurons: the purifying performance is a lot worse when the available training data is insufficient.
This largely limit the practicality of the defense as it can be hard to access sufficient original training data in real-world scenarios.
In this paper, we propose the Adversarial Weight Masking (AWM) method, a novel backdoor removal method that is capable of erasing the neuron backdoor even in the one-shot setting.
Specifically, AWM adopts a minimax formulation to adversarially (soft) mask certain parameter weights in the neuron network.
Intuitively, AWM aims to lower the weights on parameters that are related to the backdoor triggers while focusing more on the robust features [24].
Extensive experiments on backdoor removal with various available training data sizes demonstrate that our method is more robust to the available data size and even works under the extreme one-shot learning case while other baseline cannot.
As a side product, we also found that AWM’s backdoor removal performance for smaller sized networks are significantly better compared to other baselines.
Related Works
There exists a large body of literature on neural backdoors.
In this section, we only review and summarize the most relevant works in backdoor attacks, defenses and adversarial training.
Backdoor Attacks The backdoor attack aims to embed predefined triggers into a DNN during training time.
The adversary usually poisons a small fraction of training data through attaching a predefined trigger and relabeling them as corresponding target labels, which can be the same for all poisoned samples [6, 15] or different for each class [37].
In contrast, clean-label attacks [42, 1] only attach the predefined trigger to data from a target class and do not relabel any instances.
On the design of backdoor triggers, BadNets attack [15] is the first to patch instances with a white square and reveal the backdoor threat in the training of DNNs.
[32] optimizes trojan triggers by inversing the neurons.
To make the triggers harder for detection, [44] proposed an adaptive adversarial training algorithm that maximizes the indistinguishability of the hidden representations of poisoned data and clean data while training.
[30, 37] composites multiple or sample-aware trojan triggers to elude backdoor scanners.
[6] first proposed the necessity of making triggers invisible and generated poisoned images by blending the backdoor trigger with benign images instead of by patching directly.
Following this idea, some other invisible attacks [27, 29] are also prevailing, suggesting that poisoned images should be indistinguishable compared with their benign counter-part to evade human detection.
Backdoor Defenses Opposite to backdoor attack, backdoor defense aims to detect a triggered model or remove the embedded backdoor .
For the purpose of detection, the defender may detect abnormal data before model training [46, 35, 10, 12] or identify poisoned model after training [52, 58].
Another line of research focuses on backdoor removal through various techniques including fine-tuning [51, 16, 53], distillation [7], or model ensemble [28, 26].
DeepSweep [41] searches data augmentation functions to transform the infected model as well as the inference samples to rectify the model output of trigger-patched samples.
However, this method relies on the access to the poisoned data.
Recently, [59] formalizes backdoor removal as a minimax problem and utilizes the implicit hypergradient to solve it.
As it needs fine-tuning the parameters, performance decay may happen when the available fune-tuning data is limited.
Another latest work [56] discovers that backdoored DNNs tend to collapse and predict target label on clean data when neurons are perturbed, and therefore pruning sensitive neurons can purify the model.
From empirical studies, we still discover that it cannot maintain its efficacy with a small network and one-shot learning.
Adversarial Training Our work is also related to study of adversarial training [36], which adopts minmax robust optimization techniques for defending against adversarial examples [13, 49, 23, 5, 4, 8]. [60] theoretically studies the trade-off between natural accuracy and robust accuracy.
[61] proposes friendly adversarial training with better trade-off between natural generalization for adversarial robustness.
Recent study [55] also reveals the relationship between robustness and model width.
Several works also study accelerating adversarial training in practice [43, 3, 54].
Preliminaries and Insignts 3.1 Preliminaries
Defense Setting.
We adopt a typical defense setting where the defender outsourced a backdoored model from an untrusted adversary.
The defender is not aware of whether the model is been backdoored or which is the target class.
The defender is assumed to have access to a small set of training data (or data from the same distribution) but no access to the entire original training data.
Adversarial Neuron Pruning.
ANP [56] is one of the state-of-the-art backdoor removal method that adversarially perturbs and prunes the neurons without knowing the exact trigger patterns.
Denote w and b as the weight and bias of the network.
Considering a DNN f with L layers, let’s denote the k -th neuron in the l -th layer as z ( l ) k
= σ ( w ( l ) k z ( l − 1) + b ( l ) k ) , where σ is the activation function.
ANP works by first finding the neurons that are possibly compromised to the trigger patterns and then prune them out to remove the backdoors.
Specifically, it will first perturb all the neurons in DNN by multiplying small numbers δ ( l ) k and ξ ( l ) k on the corresponding weight w ( l ) k and bias b ( l ) k respectively.
Then we have z ( l ) k
= σ ((1 + δ ( l ) k ) w ( l )
k z ( l − 1) + (1 + ξ ( l ) k ) b ( l ) k ) as the new neuron output.
To simplify the notation, let’s denote ◦ as the above multiplication on the neuron-level, n as the total number of neurons, ϵ the maximum level of perturbation.
Then the goal of this perturbation is to find the perturbation that can maximize the classification loss:
[Equation]
Note that δ and w have different dimensions so that the perturbation is not weight-wise but neuronwise.
Those weights corresponding to the same neuron are multiplied with the same perturb fraction δ .
[56] claimed that by solving problem (2.1), we can identify sensitive neurons related to potential backdoors.
With the solved δ and ξ , the second step is to optimize the mask for neurons with the following objective:
[Equation]
By solving the above min-max optimization, the poisoned model prunes those sensitive neurons detected by neuron perturbation and removes the potential backdoors.
Note that when BatchNorm (BN) [25] layer is used, ANP’s perturbation on w and b will be canceled out by the batch normalization and nothing changes after BN layers.
Therefore, the implementation ANP directly perturb the scale and shift parameters in the BN layers in such cases.
3.2 Problems of ANP
ANP [56] claims to be an effective backdoor removal method without knowing the exact trigger pattern, and since it does not really fine-tune the model but directly prune the neurons, it can preserve decent model accuracy on the clean tasks.
However, its backdoor removal performance largely depends on the effectiveness of identifying the sensitive neurons regarding the backdoor trigger: if Eq. (3.2) failed to identify the accurate binary mask m , ANP will perform badly on backdoor removal tasks.
Unfortunately, in certain practical settings, ANP does fail to: 1) remove the backdoor when the available clean training data size is extremely small; 2) maintain high accuracy on clean tasks when the network size is small and the BN layer is used.
We select the BadNets attack for illustration and set the target class as 8 to train the backdoored models.
First, we test the ANP performances with various sizes of available training data.
The left part of Figure 1(a) shows that the perturbed neurons (by ANP) tend to predict the target class a lot more often than other classes when the size of available training data is sufficient, however, when the size of available data drops to 10 , it can no longer effectively indicates such pattern and the prediction portion on different classes distributes quite evenly.
As an immediate result, ANP’s backdoor removal performance significantly degrades when the size of available data is small (Figure 1(a) right part).
We then investigate how the network size affects ANP’s performance by applying it on both VGG (small) and ResNet-18 (large) backdoored models.
The left part of Figure 1 (b) indicates that while
ANP’s perturb neuron is able to show larger prediction portion on the target class, when applying on smaller VGG model, its magic failed again.
The right part of Figure 1 (b) illustrates the ASR/ACC of the ANP pruned models under various pruning threshold.
We can observe that it is hard to find a suitable pruning threshold for the smaller VGG network to obtain both high ASR and low ACC.
Our Proposed Method
In this section, we introduce our proposed method.
Inspired by the above analysis in Section 3, we propose Adversarial Weight Masking (AWM) for better backdoor removal under practical settings.
Soft Weight Masking.
From the analysis in Section 3, the neuron pruning method can be inappropriate when the backdoored model (with BN layers) is small and only has few layers: pruning certain neurons in the BN layer cuts off the information from a whole channel, which inevitably ignores some certain beneficial information for the clean tasks.
To fix this drawbacks, we propose to adopt weight masking instead of neuron pruning.
Let’s denote θ ∈ R d as the entire neural network weights.
[Equation]
where δ denotes the small perturbations on the network parameters, m is the weight mask of the same dimension as θ , ⊙ denotes the Hadamard product (element-wise product).
Eq.
(4.1) follows the general idea of ANP by first identifying the sensitive part of the neural network and then lower such sensitivity.
The major changes here is that we are no longer pruning out the neurons, instead, we add an additional mask for all the network weights.
Note that such design would provide more flexibility in removing backdoor-related parts and thus avoid over-killing in BN layers.
Since we apply weight masking instead of neuron pruning, we can also use soft mask m ∈ [0 , 1] d instead of binary neuron masks as in ANP [56].
Adversarial Trigger Recovery.
Another issue identified in Section 3 is that ANP performs poorly when the available training data size is small.
And it seems that under such challenging conditions, perturbing the mask itself does not give clues to which part of the network is really sensitive to the backdoor triggers.
Inspired from adversarial training literature [36], we can first optimize the following objective for adversarially estimate the worst-case trigger patterns:
[Equation]
where ∥ · ∥ 1 denotes the L 1 norm and τ limits the strength of the perturbation.
Note that technically speaking, Eq.
(4.2) only aims to find a L 1 norm universal perturbation that can mislead the current model toward misclassification.
Yet since we are not aware of the target class, this is a reasonable surrogate task for the trigger recovery.
Based on Eq.
(4.2), we can integrate it with soft weight masking and formulate it as a min-max optimization problem:
[Equation]
where α and β are tunable hyper-parameters.
Sparsity Regularization.
To push our defense to mask out backdoor-related weights more aggressively, we adopt the L 1 norm regularization on m for further controlling its sparsity level, as inspired by previous works [51, 48] on trigger optimization.
Combining soft weight masking, adversarial trigger recovery together with sparsity regularization on m , gives the full Adversarial Weight Masking formulation:
[Equation]
where α , β and γ are tunable hyper-parameters.
Intuitively, AWM works by first identifying the worst-case universal triggers (which are highly likely to be the actual triggers or different patterns with similar backdoor effects), and then finding an optimal weight mask m to lower the importance on the identified triggers while maintaining the accuracy on clean tasks.
Unlike ANP, which directly prunes out the suspicious neurons, we aim at learning a soft mask for each parameter weight, i.e., each element in m lies in between [0 , 1] .
Such design can help preserve the information beneficial to the clean tasks and thus avoid over-killing.
Moreover, adopting soft masks can also avoid the problem of setting the hyper-parameters on the pruning threshold, which is also heuristic and hard to generalize for various experimental settings. L inner = L ( f ( x + ∆ ; m ⊙ θ ) , y ) 7: ∆ = ∆ − η 1 ∇ ∆ L inner 8: end for 9: Clip ∆ : ∆ = ∆ × min(1 , τ ∥ ∆ ∥ 1 ) //
Phase 2: Outer Optimization 10: for t = 1 to T do 11: L outer = α L ( f ( x ; m ⊙ θ ) , y ) + β L ( f ( x + ∆ ; m ⊙ θ ) , y ) + γ ∥ m ∥12: m = m + η 2 ∇ m L outer 13: Clip m to [0 , 1] .
14: end for 15: end for
Output: Filter masks m for weights in network f .
Algorithm Details. The detailed steps of AWM is summarized in Algorithm 1.
We solve the min-max optimization problem in Eq.
(D.1) by alternatively solving the inner and outer objectives.
Specifically, we initialize all the mask values as 1 .
In each epoch, we repeat the following steps: 1) initialize ∆ as 0 , and then perform K -steps of gradient descent on ∆ and clip it with its L 1 norm limit τ ; 2) we update soft weight mask in the outer optimization via stochastic gradient descent, where the first term is to minimize the clean classification loss, the second term is for lowering the weights associated with ∆ , and the third term is the L 1 regularization on m , followed by a clipping operation to keep m within [0 , 1] .
Note that we reinitialize ∆ in each inner optimization as we need to relearn the adversarial perturbation based on the current m ⊙ θ .
We also on purposely set T > 1 for ensuring sufficient optimization during each update in order to reach better convergence.
Experiments
In this section, we conduct thorough experiments to verify the effectiveness of our proposed AWM method and analyze the sensitivity on hyper-parameters via ablation studies.
Datasets and Networks.
We conduct experiments on two datasets: CIFAR-10 [ ? ] and GTSRB [20].
CIFAR-10 contains 50000 training data and 10000 test data of 10 classes.
GTSRB is a dataset of traffic signal images, which contains 39209 training data and 12630 test data of 43 classes.
The poisoned model is trained with full training data with 5% poison rate on Resnet-18 [18], ShuffleNet
V2 [34], MobileNet V2 [21], or a small VGG [45] network with three simplified blocks, containing six convolution layers followered by BN layers.
See Appendix A for more experimental setting details and Appendix B for results on GTSRB.
Attacks and Defenses.
For the backdoor attack baselines, we consider 1) BadNets with square trigger (BadNets) [15]; 2) Trojan-Watermark (WM) and Trojan-Square (SQ) [32]; 3) l 0 -inv and l 2 -inv [27], two invisible attack methods with different optimization constraints; 4) Blended attack (BLD) [6]; 5) Clean-label attack (CLB) [50]; 6) WaNet [38] with both single target and all-to-all (a2a) target settings.
We mainly compare our method with two latest state-of-the-art methods of backdoor removal: Implicit Backdoor Adversarial Unlearning (IBAU) [59], Adversarial Neuron Pruning (ANP) [56].
Evaluations.
We adopt two metrics: ACC and ASR.
ACC is the test accuracy on clean dataset, while
ASR is calculated as the ratio of those triggered samples that are still predicted as the adversary’s target labels.
Note that usually a benign classifier is not assciated with a specific trigger, thus its prediction on poisoned data mainly follows its prediction on clean data.
Under such case, suppose we have c classes in total, we can expect the ASR should be around 1 /c , that is, 10% for CIFAR-10 and 2 .
3% for GTSRB.
Therefore, once the backdoor removal method achieves an ASR close to 1 /c (less than 1 . 5 /c ), we consider it as successfully remove the backdoor (rather than achieving ASR = 0% ) [Table]
5.1 Backdoor Removal with Various Available Data Size
[Table]
We first study the backdoor removal performances of AWM on various available data sizes and compare with other state-of-the-art defense baselines.
Table 1 presents the defense results on the CIFAR-10 dataset.
Specifically, among the entire CIFAR-10 training data, 2500 images are backdoored.
We test with varying size of available data samples ranging from 5000 to 10 for each defense.
A fixed number of 5000 remaining samples are used to evaluate the defense result
[Table] The left column depicts five single-target attack methods, and the first row represents two different adopted network structures.
Note that each attack’s poison rates are set to be 5% . We present the ACC and ASR under each backdoor removal setting in the table. All single-target attacks are capable of achieving an ASR close to 100% and an ACC around 88% with no defenses.
For Resnet-18, the performance of the baselines are comparable with AWM when there are sufficient available training data ( n = 5000 ): all methods effectively remove the backdoors.
With the decreasing size of clean data, IBAU suffers from huge performance degradation and fails to remove the backdoor under several settings.
The major reason is that its fine-tuning procedure can actually hurt the original information stored in the parameters that are crucial to its clean accuracy, especially when fine-tuning on small sample set.
On the other hand, ANP shows better robustness as it prunes the neurons which reduces the negative effect of insufficient data, but still fails on more challenging cases.
On the right part of Table 1, we can observe that ANP losses more accuracy on the small VGG network, which backup our analysis in Section 3.
AWM shows state-of-the-art backdoor removal performances with various available data sizes, network structures and successfully erase the neuron backdoors in most cases.
[Table]
We further conduct experiments in an extreme one-shot setting, i [Table] e., we only provide one image per class as the available data for backdoor removal tasks (total size as 10 for CIFAR-10 dataset).
Tableshows the result of ACC and ASR under such a one-shot setting.
In this case, we randomly sample one image for each of the ten classes and use the basic data-augmentation method, such as random horizontal flip and random crop.
As a result, our AWM successfully removes all those backdoors with minimal performance drop ( 10% higher than other baselines on average). In contrast, other baselines failed in removing the existing backdoor triggers for most cases (as suggested by the large ASR values). 5.2 Reliability of AWM under Different Attack Types and Network Architectures
[Table]
To comprehensively show our performance on different network structures and attack types, we select two more lightweight networks and four more backdoor attacks to conduct experiments under the one-shot setting.
We summarize the ACC and ASR on
CIFAR-10 in Table 3.
Robustness on Network Architectures.
Different from the
VGG we adopted to illustrate "a small network", ShuffleNet and
MobileNet contain more convolutional and BN layers while their parameters are fewer.
Although the performance gap between ANP and AWM closes up a little bit, AWM still consistently cleans up all the backdoors with better clean task performances.
This phenomenon also gives us insights that the performance of neuron pruning methods may be related to network depth more than the amount of parameters.
To sum up, AWM works well on various structures of small neural networks with limited resources.
Robustness on Trigger Types.
AWM accommodates different types of triggers as it does not make an assumption on the formulation of triggers.
Although we used the adversarial trigger recovery and sparsity regularization as parts of techniques, they do not put a constraint on the triggers to be fixed or sparse but help remove the non-robust features in the poisoned network from the root.
The results on Blend, CLB, and WaNet also support the reasoning.
The Blend attack uses gaussian noise (poison rate = 1% ) that covers the whole image.
We adopted the CLB attack with adversarial perturbations and triggers on four corners.
WaNet warps the image with a determined warping field as poisoned data, so there does not exist a fixed trigger pattern.
As it uses a noisy warping field to generate noisy data with actual labels, it is difficult to train a backdoored model with a poison rate of 1% .
We set the poison rate as 10% .
These three attacks cover scenarios that triggers are dynamic and natural.
Thus the experimental results verify that AWM does not rely on universal and sparse triggers.
The above-mentioned attacks are mostly all-to-one, except for the CLB.
To fill the blank of all-to-all attacks, we perform all-to-all attacks with WaNet on CIFAR-10 and the all-to-all attack with
Trojan-SQ pattern on GTSRB in Appendix B.
In conclusion, AWM performs well on fixed, universal, dynamic triggers and all clean label, all-to-one, and all-to-all attack settings.
5.3 Ablation Study on Each Component of AWM
[Table]
We further perform an ablation study on each component of AWM.
For notational simplicity, we refer the soft weight masking as SWM [Table] and adversarial trigger recovery as ATR.
From left to right in Table 4, we demonstrate the performance of the original ANP method, ANP + SWM (as in Eq.
(4.1)), ANP + SWM + ATR (as in Eq.
(4.3), and our full AWM method.
Table 4 shows that each component in AWM is non-trivial and necessary since adding each component would enhance the performance on average.
Previous analysis in Section 3 suggests two of the ANP’s weaknesses: when the network is small and when the available training data size is small.
The first weakness motivates us to adopt soft label masking.
As expected, SWM contributes more with the small VGG net and verifies that it overcomes the drawback of neuron pruning in a smaller network’s
BN layer.
The second weakness motivates us to perform adversarial trigger recovery.
From Table 4 we can easily observe ATR’s improvements in lowering the ASR and significantly improving the ACC.
The effect of L 1 regularization is comparably small but indeed forces the mask m to be sparser and thus further lowering the influence of weights associated with the recovered trigger patterns.
5.4 Additional Ablation Studies
In this section [Table] we perform additional empirical studies on the necessity of regularization and AWM’s robustness on the hyper-parameters.
We compare our AWM with the following modified models: 1)
No Clip : AWM with no ∆ clipping; 2)
No Shrink : AWM with no L 1 regularization on m ; 3) NC-NS :
AWM with no ∆ clipping and m regularization; 4) L 2 Reg : AWM with ∆ ’s L 2 regularization; 5) L [-
-]Reg NC : AWM with ∆ ’s L 2 regularization and no clipping; [Table] 28 ↑ 62.14 ↓
[Table]
68 ↑
[Table] 32 ↓ [Table] 61.68 ↓
[Table]
38 ↑
[Table]
[Table]
15 ↑ No Shrink
[Table]
32 ↓ 9.
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
36 ↑
[Table]
[Table]
86 NC NS 65.32 ↓
[Table]
[Table]
↓
[Table]
↑
[Table]
[Table]
52 ↑
[Table]
[Table]
87 ↑
[Table]
[Table]
84 ↑ L
[Table]
Reg 72.
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
35 L
[Table]
Reg NC
[Table]
[Table]
[Table]
50 ↓
[Table]
[Table]
[Table]
[Table]
[Table]
53 ↑
[Table]
[Table]
87 ↑ Full AWM 76.
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
[Table]
[Table] [Figure] Constraints on ∆ and m . In Table 5, we compare the results of different modifications of AWM.
On the one hand, the clipping of the virtual trigger ∆ is necessary as No Clip and L 2 Reg NC either remove the backdoor incompletely or sacrifice the accuracy too much.
L 2 Reg changes the form of regularization and achieves comparable results on several settings but is less stable than AWM.
The comparison between AWM and L 2 Reg also shows that both L 1 and L 2 norm regularization work for ∆ .
On the other hand, the regularization of m helps better learn the soft mask.
NC-NS differs from
No Clip only in the m but successfully unlearns more backdoors.
This is also reasonable since: by punishing the L 1 norm, the soft masks are forced to reach smaller values and thus be more aggressive on suspicious trigger-related features.
Hyper-parameters.
We first use one single defend task to test AWM’s sensitivity to hyper-parameters: the coefficient α , γ , and the clipping bound τ for ∆ .
Concretely, α controls the trade-off between the clean accuracy and backdoor removal effect, γ controls the sparsity of weight masks, and τ controls the maximum L 1 norm of the recovered trigger pattern.
We test with α ∈ [0 . 5 , 0 . 8] , β = 1 − α, γ ∈ [10 − 8 , 10 − 5 ] , τ ∈ [10 , 3000] and shows the performance changes under the Trojan-SQ attack with 500 training data.
When varying the value of one specific hyper-parameter, we fix the others to the default value as α 0 = 0 .
9 , γ
=
10 − 7 , τ 0 = 1000 .
As shown in Figure 2, γ is quite robust within the selected range.
However, if we choose an overly large γ , the mask would shrink its value and hurt the accuracy.
α works best around 0 .
8 to 0 .
If α is too close to 1 , the major goal of AWM will shift to maintain clean accuracy while paying less attention to backdoor removal.
The clipping bound τ should also be selected within a moderate range, as the adversarial perturbation should neither be too small to fail in capturing the real trigger nor be too large to lead to difficulties in finding the optimal soft mask m .
In addition, considering the data dimension for CIFAR-10, further increasing τ after 3000 is the same as no constraint and thus meaningless. As observed, the impacts of α and γ on the performance has a single decrease or increase, while the clipping bound τ needs a moderate value. To verify the difficulty of selecting τ , we then conduct experiments to compare the τ s from 10 to 3000 for four attacks, keeping α and γ to be 0.9 and 10 − 7 . [Figure]
Observing the ACC and ASR curves with Trojan-SQ,
Trojan-WM, BadNets, and L 0 -inv in Figure 3, the ACC decreases with the increase of τ while ASR first decreases fastly and then slightly increases again or keeps flat.
The reasons behind this are easy to interpret.
In terms of
ACC, since we are using a larger τ , the model weights are masked to adapt to triggered data points that are far different from the original data distribution.
As a result, this will unavoidably hurt the original task ACC.
On the other hand, in an ideal condition, ASR should decrease since the solution space of the optimization problem with larger τ actually contains the solution of the same problem with a smaller τ .
Thus in terms of backdoor removal, it should be at least as good as that of a smaller τ .
However, in practice, since we use PGD for solving the inner maximization problem, setting a large τ will simply make the
L 1 norm of the recovered trigger too large.
Thus the recovered trigger will be further away from the actual trigger and negatively affects the backdoor removal performances, especially on the variance.
Fortunately, the workable range of τ is indeed vast for various attacks, and it is pretty safe to select a value between 50 and 1000 for a 32 × 32 image, which can be easily extended to other image sizes by the ratio τ/ image size.
On the one hand, even if we falsely select an overly-large τ , such as 3000 for BadNets, the resulting ACC and ASR are still acceptable.
On the other hand, we recommend selecting small τ because it tends to outperform the default setting.
It is also reasonable to assume that the adversary tends to make a trigger invisible and small in the norm.
For example, the L 1 norm of Trojan-WM’s actual trigger is around 115, which is way smaller than our default value of τ = 1000 .
In fact, τ = 1000 roughly means that we allow the trigger to significantly change the clean image over 16 × 16 pixels in a 32 × 32 image which has been fairly large.
In this work, we propose a novel Adversarial Weight Masking method which adversarially recover the potential trigger patterns and then lower the parameter weights associated to the recovered patterns.
One major advantage of our method is its ability to consistently erasing neuron backdoors even in the extreme one-shot settings while the current state-of-the-art defenses cannot.
Under scenarios with a few hundred clean data, AWM still outperforms other backdoor removal baselines. Extensive empirical studies show that AWM relies less on the network structure and the available data size than neuron pruning based methods.
Note that currently, our AWM method still needs at least one image per class in order to erase the neuron backdoors properly. In some cases, the defender may have no clue what the training data is.
Under such settings, it would be wonderful if the model owner could also remove the backdoors in a data-free setting.
In addition, it is still under-explored how the weight masks in different layers contribute to the results.
It would also be interesting to explore whether an attacker could break the backdoor defense method with the knowledge of the optimization details.
We leave these problems as future works.
A Additional Experimental Settings
VGG Network. In this work, we follow [59] to adopt a small VGG network with the following structure.
Each convolution layer is followed by a BatchNorm layer and the activation function is ELU with α = 1 . 0 .
When using our AWM method, we need to substitute the Conv2d with MaskedConv2d.
[Table] ×
[Table] × [Table] Block
[Table] MaskedConv2d) [Table] [Table]
MaskedConv2d
[Table] [Table] [Table] [Table]
Implementation. We adopt PyTorch [39] as the deep learning framework for implementations. In implementation, the outer optimization is conducted with Adam with a learning rate of 0.01 (decay to 0.001 after 50 epochs) and the inner optimization is conducted with SGD with a learning rate of 10. We use the default hyper-parameter setting as α = 0 .
9 , β = 0 . 1 , γ = 10 − 8 , τ = 1000 for both CIFAR-10 and GTSRB datasets. The batch size for training is summarized in Table 7.
[Table]
Attack Setting.
In the single-target attack setting, we set Class 8 as the target for BadNets, Class 2 as the target for Trojan-SQ and Trojan-WM, and Class 0 as the target for l 0 -inv, l 2 inv, BLEND, and
WaNet.
In the multi-target attack setting, we use the pattern of Trojan-SQ and relabel each sample from Class n to n + 1 .
B Results on GTSRB
Table 8 presents the defense results on the GTSRB dataset.
GTSRB [20] dataset has 39209 training data and 12630 test data of 43 classes. Specifically, among the entire GTSRB training data,images are backdoored. We test with varying size of available data samples ranging from 5000 to(one-shot) for each defense. The remaining samples are used to evaluate the defense result.
The left column depicts five single-target attack methods and one multi-target attack method.
The first row represents two different adopted network structure. We present the ACC and ASR under each backdoor removal setting in the table, all attacks are capable of achieving an ASR close to 99% and an ACC around 98% with no defenses. The performance of the baselines are comparable with AWM when there are sufficient available training data ( n = 5000 ): most methods effectively remove the backdoors. Similar to CIFAR-10,
IBAU suffers from the biggest performance drop (higher ASR or fail to remove the backdoor).
As the number of samples of Class 0 is smaller than Class 2 in GTSRB, it is much easier to remove the backdoor of l 0 -inv and l 2 -inv and achieve a very low ASR.
However, in other attack settings, we can still observe that ANP is negatively affected by insufficient data.
On the left part of Table 8, we can observe that ANP performs worse on the small VGG network, which backup our analysis in the paper.
AWM shows state-of-the-art backdoor removal performances overall in this table.
As there are more classes in GTSRB than CIFAR-10, more instances are available in the one-shot setting, we do not use any data augmentation.
Our AWM successfully removes all those backdoors while other baselines failed in removing the existing backdoor triggers for certain cases.
[Table]
Convergence.
Figure 4 demonstrates the one-shot training records of ACC and ASR in each epoch of AWM over the 5 single-target attacks.
Note that we take ten steps of outer optimization after every 10 steps of inner optimization in each epoch.
The backdoors are removed very quickly in most cases.
Since we only have extremely insufficient clean data, it causes a little accuracy degradation after a long time of training.
We report the averaged ACC and ASR after 100 epochs(1000 iterations) overruns in previous table.
C Additional Studies of AWM
Masking Selected Layers. For the all-to-all attack on GTSRB, we visualize the distribution of mask values in different layers and try to achieve similar performance with masking fewer layers. Figureshows the percentage of mask values falling into each interval. Most values fall in the smallest and the largest intervals, indicating the effect of sparsity constraint.
In the following experiment, we optimize the mask on each layer on CIFAR-10 with VGG.
As shown in the Table 6, there are six convolution layers in this small VGG network. We name VGG-i as the VGG with only mask on the i -th convolution layer. We summarize the backdoor removal result with 100 instances in Table 10.
Masking shallow convolution layers, such as VGG-1, 2, and 3, is much easier to remove the backdoor comparing with masking deep layers.
Another phenomenon is that masking the first convolution layer causes the largest loss on accuracy.
This inspires that it might be possible to save the number of masks by limiting them in shallow layers.
[Table]
We also visualizes the distribution of weight mask values in Figure 6.
Note that this heatmap summarizes the six experiments and each row corresponds to the mask values in the specific layer.
Figure 6 is similar to Figure 5: Overall, it shows that optimizing masks on a certain layer is dependent to other layers to some degree.
Therefore, it is reasonable to consider separating or selectively optimizing masks on some layers, which we leave as future work
[Table]
Defend Against Multiple Triggers .
It is interesting to explore how to break a backdoor defense method with knowledge of how it works.
Some principles in developing backdoor attacks, such as making triggers invisible or natural, are data-driven and do not direct a specific backdoor removal optimization procedure.
The corresponding adaptive attack can potentially be complex on the device since the current backdoor removal techniques, including our AWM, have already involved complicated bi-level optimization.
As an attempt, we design a simple method targeting our backdoor trigger reconstruction mechanism: we only estimate one universal trigger ∆ in every iteration.
Now suppose the attacker knows our design and decides to inject multiple backdoor patterns into the model.
They would hope our design could only remove one of them and thus fail on the other triggers.
The following table summarizes the result of defending against multiple backdoor triggers on CIFAR10.
We first train a poisoned model using three triggers: BadNets, Trojan-WM, and L 2 -inv.
The overall poison rate is set as 5% .
Then we apply our AWM to remove the backdoors.
ASR (all) represents the attack success rate as long as any one of the three triggers fooled the model.
ASR1,
ASR2, and ASR3 represent the attack success rate of each of the three triggers. Finally, ACC is the test accuracy on the clean test set. The results show that adding multiple triggers still cannot penetrate our AWM defense even with limited resources. [Table]
We conjecture that this is because although multiple triggers are involved, our algorithm will still try to identify the most likely triggers in each iteration. Thus when the first (the most prominent) ‘trigger’ is removed, the algorithm will automatically target the next likely ‘trigger’. Such backdoor removal strategies seem to be hard to penetrate. Successful attacks may need to leverage tri-level optimization problems, which are notoriously hard to solve, or aim to make the removal strategy impractical by lowering its natural accuracy, which currently has no concrete solutions.
We also leave this problem as one of our future work directions.
D Objectives in Ablation Study
We list the formal objective functions for the five modifications of AWM compared with in Section 5.3 of our paper.
Full AWM
[Equation]
1) No Clip : AWM with no ∆ clipping: [Equation] where β is set to be 1 − α . 2) No Shrink : AWM with no L 1 regularization on m ;
[Equation]
3) NC-NS : AWM with no ∆ clipping and m regularization;
[Equation]
L 2 Reg : AWM with ∆ ’s L 2 regularization; min m ∈
[Equation] [Equation] [Equation] ) ∼ D
[Equation]
f
[Equation]
x
[Equation]
m ⊙
[Equation]
) , y )
[Equation]
β max ∥ ∆
[Equation]
2 ⩽
[Equation]
⊙
[Equation]
L 2 Reg NC : AWM with ∆ ’s L 2 regularization and no clipping; min m ∈ [
[Equation]
1] d E ( x ,y ) ∼ D α L ( f ( x ; m ⊙ θ ) , y ) + β
[Equation]
L
[Equation]