S ELF - ENSEMBLE A DVERSARIAL T RAINING FOR I MPROVED R OBUSTNESS
A BSTRACT
Due to numerous breakthroughs in real-world applications brought by machine intelligence, deep neural networks (DNNs) are widely employed in critical applications.
However, predictions of DNNs are easily manipulated with imperceptible adversarial perturbations, which impedes the further deployment of DNNs and may result in profound security and privacy implications.
By incorporating adversarial samples into the training data pool, adversarial training is the strongest principled strategy against various adversarial attacks among all sorts of defense methods.
Recent works mainly focus on developing new loss functions or regularizers, attempting to ﬁnd the unique optimal point in the weight space.
But none of them taps the potentials of classiﬁers obtained from standard adversarial training, especially states on the searching trajectory of training.
In this work, we are dedicated to the weight states of models through the training process and devise a simple but powerful Self-Ensemble Adversarial Training (SEAT) method for yielding a robust classiﬁer by averaging weights of history models.
This considerably improves the robustness of the target model against several well known adversarial attacks, even merely utilizing the naive cross-entropy loss to supervise.
We also discuss the relationship between the ensemble of predictions from different adversarially trained models and the prediction of weight-ensembled models, as well as provide theoretical and empirical evidence that the proposed self-ensemble method provides a smoother loss landscape and better robustness than both individual models and the ensemble of predictions from different classiﬁers.
We further analyze a subtle but fatal issue in the general settings for the self-ensemble model, which causes the deterioration of the weight-ensembled method in the late phases * .
I NTRODUCTION
Deep learning techniques have showed promise in disciplines such as computer vision (Krizhevsky et al., 2012;
He et al., 2016), natural language processing (Vaswani et al., 2017; Devlin et al., 2019), speech recognition (Sak et al., 2015; Wang et al., 2017) and even in protein structural modeling (Si &
Yan, 2021; Jumper et al., 2021).
However, even for those efforts surpassing human-level performance in several ﬁelds, deep learning based methods are vulnerable to adversarial examples generated by adding small perturbations to natural examples (Szegedy et al., 2014; Goodfellow et al., 2015).
Following the discovery of this adversarial vulnerability (Ma et al., 2020; Wang et al., 2020b; Niu et al., 2021), numerous defense approaches for protecting DNNs from adversarial attacks have been proposed (Papernot et al., 2016; Xu et al., 2018;
Liao et al., 2018; Ross & Doshi-Velez, 2018; Bai et al., 2019; Qin et al., 2020; Wang et al., 2020a; Bai et al., 2021;
Huang et al., 2021)
Because it is a straightforward and effective data-driven strategy, among these methods, adversarial training (Madry et al., 2018) has become the de-facto way for strengthening the robustness of neural networks.
The core of adversarial training is proactively inducing a robust model by forcing DNNs to learn adversarial examples generated from the current model, which helps DNNs gradually make up for their deﬁciencies.
Therefore, it is a practical learning framework to alleviate the impact of adversarial attacks.
As a saying goes, a person may go faster but a team can go farther.
An ensemble of classiﬁers fused by output aggregates the collective wisdom of all participated classiﬁers, which outperform the decision made by a single classiﬁer.
Many ensemble methods (Tram`er et al., 2018; Pang et al., 2019) have shown their abilities to boost adversarial robustness.
Despite averaged predictions of different models enables the aggregation against a large number of attacks, it is still a heavy computing burden to adversarially train all the member models.
What is worse, the architectures and parameters of every member model, as well as their related contribution factors, should be safely saved and need performing forward propagation for every member repeatedly, which is a nightmare when dealing with massive components.
Despite the fact that the ensemble technique adopts a variety of architectures and parameters, these models may have similar decision-making boundaries.
Therefore, it is natural to wonder:
Could we develop the potential of the classiﬁer itself to build a robust model rather than rely on multiple seemingly disparate classiﬁers?
Could we make use of states on the searching trajectory of optimization when performing adversarial training?
Motivated by these questions, we discuss the relationship between an ensemble of different classiﬁers fused by predictions and by parameters, and present a computation-friendly self-ensemble method named SEAT.
In summary, this paper has the following contributions:
• By rethinking the standard adversarial training and its variants, instead of developing a well-designed loss to ﬁnd a single optimal in the weight space, we design an efﬁcient algorithm called Self-Ensemble Adversarial Training (SEAT) by uniting states of every history model on the optimization trajectory through the process of adversarial training.
Unlike the traditional ensemble technique, which is extremely time-consuming and repeating adversarial training procedures for individuals, SEAT simply requires training once.
• We present a theoretical explanation of the differences between the two ensemble approaches discussed above and visualize the change of loss landscape caused by SEAT.
Furthermore, while using data augmentation of external data can experimentally ﬁx the deterioration during the late stages (Gowal et al., 2020; Rebufﬁ et al., 2021), we further investigate a subtle but fatal intrinsic issue in the general settings for the self-ensemble model, which causes the deterioration of the weight-ensembled method.
• We thoroughly compare adversarial
robustness of SEAT with other models trained by the state-of-the-art techniques against several attack methods on CIFAR-10 and CIFARdatasets.
Results have shown that the SEAT method itself can efﬁciently search in the weight space and signiﬁcantly improve adversarial robustness.
R EVIEW : S TANDARD A DVERSARIAL T RAINING AND ITS S UCCESSORS
In this section, we ﬁrst introduce basic concepts of adversarial training.
Then we brieﬂy review some variants and enhancements of standard adversarial training.
2. P RELIMINARIES
Consider a standard image task which involves classifying an input image into one of C classes, let x ∈ [0 , 1] n denote the input natural image and y ∈ { 1 , 2 , . .
, C } be the ground truth label, sampled from a distribution D .
For adversarial attack, the goal of the adversary is to seek a malignant example in the vicinity of x , by adding a human imperceptible perturbation ε ∈ R n .
To exactly describe the meaning of “imperceptible”, this neighbor region B ε ( x ) anchored at x with apothem ε can be deﬁned as B ε ( x )
= { ( x (cid:48) , y ) ∈ D | (cid:107) x − x (cid:48)
(cid:107) ≤ ε } .
We also deﬁne a loss function: (cid:96) def =
Θ × D → [0 , ∞ ) , which is usually positive, bounded, and upper-semi continuous (Blanchet & Murthy, 2019; Villani, 2003; Bartlett & Mendelson, 2001) for all θ ∈ Θ .
Instead of the original formulation of adversarial training (Szegedy et al., 2014; Goodfellow et al., 2015), which mixes natural examples x and adversarial examples x (cid:48) together to train models, the adversarial risk minimization problem can be formulated as a two-player game that writes as below:
[Equation]
In general
[Equation]
the adversary player computes more and more harmful perturbations step by step, where the PGD method (Madry et al., 2018) is commonly applied:
[Equation]
where κ is the step size and the generated samples at each iteration will be projected back to the B ε ( x ) .
When ﬁnding x (cid:48) at their current optimal in the inner maximization, the model parameters will be updated according to these ﬁxed samples only in the outer minimization.
2. R ELATED W ORK
Emerging adversarial training methods are primarily concerned with strengthening their robustness through empirical defense.
Here we roughly separate these improvements into two categories: (1) sample-oriented (i.e. for x (cid:48) in the inner maximization) and (2) loss-oriented (i.e. for (cid:96) in the outer minimization) improvement.
From the side of the former, Baluja & Fischer (2017) utilize a GAN framework to create adversarial examples via the generative model.
Wang et al.
(2019) proposes a criterion to control the strength of the generated adversarial examples while FAT (Zhang et al., 2020) control the length of searching trajectories of PGD through the lens of geometry.
For the latter, a stream of works have been carried out with the goal of establishing a new supervised loss for better optimization.
Usually, the loss (cid:96) in the both inner maximization and outer minimization † are cross-entropy deﬁned as: (cid:96) ce
= − y T log q when given the probability vector q =
[e f θ ( x (cid:48) ) 1 , · · · , e f θ ( x (cid:48) )
c ] / (cid:80) c
k =1 e f θ ( x (cid:48) )
k .
The addition of a regularizer to the vanilla loss is one branch of the modiﬁcation.
Representative works like ALP (Kannan et al., 2018), TRADES (Zhang et al., 2019), and VAT (Miyato et al., 2019) introduce a regularization term to smooth the gap between the probability output of natural examples and adversarial ones, which can be denoted as:
[Equation]
where η is the regularization hyper-parameter and R ( · , · ) is l 2 distance for ALP and VAT ‡ , and
Kullback-Leibler divergence for TRADES.
B stands for the sampled minibatch.
Another branch of the loss modiﬁcation is to reweight the contributions of each instance in the minibatch based on their intrinsic characteristics.
This can be formulated by:
[Equation]
where w ( · ) is a real-valued function mapping the input instances to an importance score.
MMA (Ding et al., 2020) separately considers the correct and incorrect classiﬁcation on natural cases and switches between them by learning a hard importance weight:
[Equation]
where w 1 and w 2 are the indicator function 1 ( f θ ( x i ) (cid:54)
=
y i ) and 1 ( f θ ( x i ) =
y i ) , respectively.
Inspired by the geometry concern of FAT, GAIRAT (Zhang et al., 2021) evaluates w ( θ ; x, y ) =
(1 + tanh( c 1 − 10 c 2 + 5)) / 2 to adaptively control the contribution of different instances by their corresponding geometric distance of PGD, where c 1 is a hyper-parameter and c 2 is the ratio of the minimum successful iteration numbers of PGD to the maximum iteration step.
Embracing both two schools of improvement, MART (Wang et al., 2020c) adds a new regularization term apart from KL divergence and explicitly assigns weights within regularizers:
[Equation]
where R KL is Kullback-Leibler divergence same as TRADES and w i
= (1 − p ( θ ; x i , y i )) is a softer scheme when compared with MMA.
The margin term R mag = − log
[Equation]
1 − max k
[Equation]
=
[Equation]
i
[Equation]
i , y
[Equation]
) aims at improving the decision boundary.
The above methods endeavor to solve the highly non-convex and non-concave optimization in Eqn 1.
However, they assume that the optimal weights of a classiﬁer appear in its prime and abandon all the states along the route of optimization, which are beneﬁcial to approach the optimal.
Input:
[Table]
parameters
[Table]
Initialize θ ←
[Table] [Table]
θ ← θ .
for t ← 1 , 2 , · · ·
[Table]
N do
Sample a minibatch (x, y) from
[Table]
distribution D x (cid:48) 0 ←
[Table]
Uniform
[Table]
for
[Table] [Table]
[Table]
do
[Table]
end for
[Table]
Calculate τ
[Table]
according to the
[Table]
+
[Table]
end for Return
A self-ensemble adversarial training model f ˜ θ ( · )
M ETHODOLOGY
In this section, we ﬁrst discuss the traditional ensemble methods based on predictions of several individual classiﬁers.
Then, we propose a Self-ensemble Adversarial Training (SEAT) strategy fusing weights of individual models during different periods, which is both intrinsically and computationally convenient.
Following that, we further provide theoretical and empirical analysis on why the prediction of such an algorithm can make a great difference from that of simple ensembling classiﬁers.
3. P REDICTION - ORIENTED E NSEMBLE
Ensemble methods are usually effective to enhance the performance (Caruana et al., 2004; Garipov et al., 2018) and improve the robustness (Tram ` er et al., 2018; Pang et al., 2019).
For clarity, we denote
F as a pool of candidate models where F = { f θ 1 , · · · , f θ n } .
To represent the scalar output of the averaged prediction of candidate classiﬁers over C categories, we deﬁne the averaged prediction ¯ f involving all candidates in the pool F as:
[Equation]
where β represents the normalized contribution score allotted to the candidates.
It is logical to assume that ∀ β i > 0 since each candidate model must be well-trained, otherwise it will be expelled from the list.
Note that here we only discuss whether the participated model performs well on its own, not whether it has a positive impact on the collective decision making, which is a belated action.
3. S ELF - ENSEMBLE A DVERSARIAL T RAINING
In order to average weights of a model, it is natural to choose an analogous form as Eqn 7 to obtain the predicted weights: ˜ θ = (cid:80)
Tt =1 β t θ t , s.t.
(cid:80)
Tt =1 β t = 1 .
However, such a simple moving average cannot keenly capture the latest change, lagging behind the latest states by half the sample width.
To address this problem, we calculate the optimal weights by characterizing the trajectory of the weights state as an exponential moving average (EMA) for measuring trend directions over a period of time.
Intuitively, EMA not only utilizes recent proposals from the current SGD optimization but also maintains some inﬂuence from previous weight states:
[Equation]
Because α is usually assigned to a value approaching 1, it is clear that EMA places a greater weight and signiﬁcance on the most recent weight states.
Algorithm1 summarizes the full algorithm.
In consideration of both using the moving average technique, we wonder whether the averaged prediction has a link to the prediction of a weight-averaged model.
In fact, they are indeed related to each other to some extent:
Proposition 1.
(Proof in Appendix B) Let f θ ( · ) denote the predictions of a neural network parametrized by weights θ .
Assuming that ∀ θ ∈ Θ , f θ ( · ) is continuous and ∀ ( x, y ) ∈ D , f θ ( x, y ) is at least twice differentiable.
Consider two points θ t , ˜ θ ∈ Θ in the weight space and let ξ = θ t − ˜ θ , for t ∈ { 1 , 2 , · · · , T } , the difference between ¯ f F ( x, y ) and f ˜ θ ( x, y ) is of the second order of smallness if and only if (cid:80)
Tt =1 ( β t ξ T )
= 0 .
Based on Proposition 1, we could immediately obtain the below conclusions:
Remark 1.
Note that it always constructs ensembles of the well-matched enhanced networks to obtain stronger defense, so it evenly assigns β 1 = β 2 = · · · = β n = 1 /n .
However, things change in the selfensemble setting since models obtained at relatively late stages will be much robust than the beginning.
Based on this assumption, it has a non-increasing sequence β 1 ≤ β 2 ≤ · · · ≤ β n , s.t.
(cid:80)
ni
=1 β i = 1 .
The inequality is tight only when the initial weight reaches its ﬁxed point.
In this case, the averaged prediction will predispose to the models obtained at the end of optimization and such a predisposition loses the superiority of ensemble due to the phenomenon of homogenization in the late phases.
To provide an empirical evidence of homogenization of models at latter periods, we visualize the effect of homogenization along the training process in Figure 1a.
We deﬁne the homogenization of a model as: (cid:52) e = 1 ||D|| min i ∈ [1 ,m ] | f θ e ( x, y ) − f θ e − i ( x, y ) | , used for calculating the difference of the output of history models over a period of time m .
Note that (cid:52) e becomes smaller and smaller along with epochs passing, which proves the existence of homogenization.
[Figure]
Here we formally state the gap between such an averaged prediction and the prediction given by
SEAT in the following theorem:
Theorem 1.
(Proof in Appendix B) Assuming that for i, j ∈ { 1 , · · · , T } , θ i
= θ
j if and only if i = j .
The difference between the averaged prediction of multiple networks and the prediction of SEAT is of the second order of smallness if and only if β i =
(1 − α )
α i − 1 for i ∈ { 1 , 2 , · · · , T } .
Theorem 1 tells us that it is much harder for SEAT to approximate the averaged prediction of history networks than the SMA method.
So the prediction of SEAT keeps away from the averaged prediction of models, which suffers from homogenization.
To ensure whether the difference in Theorem 1 is benign, we provide empirical evidence of the improvement of the self-ensemble technique on the loss landscape.
It is difﬁcult for the traditional 1D linear interpolation method to visualize non-convexities (Goodfellow & Vinyals, 2015) and
biases caused by invariance symmetries (e.g. batch normalization) in the
DNN.
Li et al.
; Wu et al.
(2020) address these challenges, providing a scheme called ﬁlter normalization to explore the sharpness/ﬂatness of DNNs on the loss landscape.
Let v 1 and v 2 are two random direction vectors sampled from a random Gaussian distribution.
So we plot the value of
[Figure]
loss function around θ when inputting data samples:
[Equation]
where m = (cid:107) θ (cid:107) (cid:107) v 1 (cid:107) , n = (cid:107) θ (cid:107) (cid:107) v 2 (cid:107) , and (cid:107)·(cid:107) denotes the Frobenius norm.
Speciﬁcally, we apply the method to plot the surface of DNN within the 3D projected space.
We visualize the loss values of ResNet on the testing dataset of CIFAR-10 in Figure 2.
Each grid point in the x-axis represents a sampled gradient direction tuple ( v 1 , v 2 ) .
It is clear that SEAT has a smooth and slowly varying loss function while the standard adversarially trained model visually has a sharper minimum with higher test error.
Safeguard for the Initial Stage : During the initial training period, the history models are less instrumental since they are not adequately learned.
Therefore, it is not wise to directly make use of the ensembled weights, which may accumulate some naive weight states and do harm to approach the oracle.
Therefore, we apply the protection mechanism for novice models at the beginning, denoted as α (cid:48)
=
min (cid:16) α, i i + c (cid:17) , where c is a constant factor controlling the length of warm-up periods for history models.
3. D ETERIORATION : T HE D EVIL IN THE L EARNING R ATE
Having provided both theoretical and experimental support as well as a clear procedure of SEAT algorithm, we may take it for granted that this self-ensemble method could be integrated into the routine working ﬂow as an off-shelf technique.
But it is not the case.
As shown in Figure 2b and 2c, while the two self-ensemble models have almost nearly identical settings, their loss landscapes are completely different (quantitative results can be referred to Appendix
A.4).
Despite the fact that the landscape of deteriorated SEAT is a little mild than the standard adversarially trained model, it is still extremely steep when compared with SEAT.
This phenomenon about deterioration is also discovered by Rebufﬁ et al.
They combine model weight averaging with data augmentation and external data to handle the deterioration.
The intention behind such a solution is robust overﬁtting (Rice et al., 2020) of individuals.
However, it is unclear why an ensemble model assembled from overﬁtting individuals performs poorly, while inferior models can still be aggregated to produce a superior one in the middle of training stages.
In the rest of this section, we provide another solution from a quite new perspective: the strategy of learning rate .
Proposition 2.
(Proof in Appendix B) Assuming that every candidate classiﬁer is updated by SGDlike strategy, meaning θ t +
=
θ t − τ t ∇ θ t f θ t ( x (cid:48) , y ) with τ 1 ≥ τ 2 ≥ · · · ≥ τ T > 0 , the self-ensemble model will inevitably worsen and the degree depends on learning rate schedules.
As illustrated in Figure 1a, we note that the phenomenon of homogenization exacerbates after each tipping point (e.g. Epoch 76, 91 and 111) when using the staircase strategy of learning rate.
Combined with the trend of robust accuracy in Figure 1b, the result demonstrates that there exists a certain learning rate τ t (cid:48) , the self-ensemble model cannot gain any beneﬁts when the current learning rate drops below this bar.
E XPERIMENTAL R ESULTS
In this section, we ﬁrst conduct a set of experiments to verify the advantages of the proposed method.
Then, we investigate how each component of SEAT functions and how it affects robust accuracy.
4. E XPERIMENTAL SETUP
We mainly use ResNet18 and WRN-32-10 (Zagoruyko & Komodakis, 2016) for the experiments on CIFAR-10/CIFAR-100 and all images are normalized into [0 , 1] .
For simplicity, we only report the results based on L ∞ norm for the non-targeted attack.
We train ResNet18 using SGD with 0.
momentum for 120 epochs and the weight decay factor is set to 3 .
5 e − 3 for ResNet18 and 7 e − 4 for
WRN-32-10.
For SEAT, we use the piecewise linear learning rate schedule instead of the staircase one based on Proposition 2.
The initial learning rate for ResNet18 is set to 0.01 and 0.1 for WRN-32till Epoch 40 and then linearly reduced to 0.001, 0.0001 and 0.01, 0.001 at Epoch 60 and 120, respectively.
The magnitude of maximum perturbation at each pixel is ε = 8 / 255 with step size κ = 2 / 255 and the PGD steps number in the inner maximization is 10.
To evaluate adversarial defense methods, we apply several adversarial attacks including PGD (Madry et al., 2018),
MIM (Dong et al., 2018), CW (Carlini & Wagner, 2017) and AutoAttack (AA) (Croce & Hein, 2020).
We mainly compare the following defense methods in our experiments:
• TRADES, MART, FAT and GAIRAT:
For TRADES and MART, we follow the ofﬁcial implementation of MART § to train both two models for better robustness.
The hyperparameter η of both TRADES and MART is set to 6.0.
The learning rate is divided by 10 at Epoch 75, 90, 100 for ResNet18 and at 75, 90, 110 for WRN-32-10, respectively.
For FAT and GAIRAT, we completely comply with the ofﬁcial implementation ¶ to report results.
• PoE: We also perform the experiments on the Prediction-oriented Ensemble method (PoE).
We select the above four advanced models as the candidate models.
When averaging the output of these models, we assign different weights to individuals according to their robust accuracy.
Speciﬁcally we respectively ﬁx β 1 , 2 , 3 , 4 = 0 . 1 , 0 . 2 , 0 . 3 , 0 .
4 for FAT, GAIRAT, TRADES, and MART, named PoE.
Considering the poor robust performance of FAT and GAIRAT, we also provide the PoE result by averaging the outputs of TRADES trained with λ = 1 , 2 , 4 , 6 , 8 and assign the same β to them, named PoE (TRADES).
• CutMix (with WA):
Based on the experimental results of Rebufﬁ et al.
(2021), Cutmix with a ﬁxed window size achieves the best robust accuracy.
We follow this setting and set the window size to 20.
Since we do not have matched computational resources with Deepmind, we only train models for 120 epochs with a batch size of 128 rather than 400 epochs with a batch size of 512.
Besides, we neither use Swish/SiLU activation functions (Hendrycks & Gimpel, 2016) nor introduce external data and samples crafted by generative models (Brock et al., 2019; Ho et al., 2020; Child, 2021) for fair comparison.
4. R OBUSTNESS E VALUATION OF SEAT
In this section, we fully verify the effectiveness of the SEAT method.
We report both average accuracy rates and standard deviations.
All results in Tables 1 and 2 are computed with 5 individual trials.
Results on ResNet18 are summarized in Table 1.
Here, we mainly report the results on the CIFARdataset due to the space limitation.
For the results on CIFAR-100, please refer to Appendix A.2.
From the table, we can see that the superiority of SEAT is apparent especially considering we only use candidate models supervised by the traditional cross-entropy loss without external data.
Compared with two advanced loss-oriented methods (TRADES and MART), the results of SEAT are at least ∼ 2% better than TRADES and MART against CW and AA.
We further emphasize that although the boost of SEAT regarding PGD attacks is slight when compared with GAIRAT, SEAT achieves startling robust accuracy results when facing CW and AA attacks.
Note that AA is an ensemble of various advanced attacks (the performance under each component of AA can be found in Appendix
A.1) and thus the robust accuracy of AA reliably reﬂects the adversarial robustness, which indicates that the robustness improvement of SEAT is not biased.
It’s worth noting that PoE is unexpectedly much weaker in defending AA attack even than its members.
We guess the poor performance of FAT and GAIRAT encumber the collective though we appropriately lower the contribution score of them.
If we switch to an ensemble of the outputs of TRADES with different λ s, the performance will be slightly improved.
That demonstrates that the robustness of every candidate model will affect the performance of the ensemble.
The negligible computational burden estimated in Appendix A.5 also demonstrates the superiority of our on-the-ﬂy parameter-averaged method of SEAT.
We also evaluate the SEAT method on WRN-32-10.
Results are shown in Table 2.
We notice that the superiority of SEAT appears to be enhanced when using WRN-32-10.
The gap between SEAT
[Table] [Table]
and advanced defense methods enlarges to at least ∼ 4% .
In the setting with data augmentation, when compared with the results of ResNet18, SEAT combined with CutMix gains much higher performance on robust accuracy against several attacks as the model becomes larger.
The observation given by Rebufﬁ et al.
(2021) shows that additional generated data would overload the model with low capacity.
When it comes to ours, we can further infer from a marginal and even a negative effect shown in Table 1 that the model with low capacity cannot beneﬁt from both external and internal generated data.
This phenomenon springs from the fact that CutMix techniques tend to produce augmented views that are far away from the original image they augment, which means that they are a little hard for small neural networks to learn.
4. A BLATION S TUDY
In this section, we perform several ablation experiments to investigate how different aspects of SEAT inﬂuence its effectiveness.
If not speciﬁed otherwise, the experiments are conducted on CIFARusing ResNet18.
[Figure]
Different Learning Rate Strategies.
The staircase learning rate technique is always applied to update weights in commonly used neural networks, which τ remains unchanged within the speciﬁc epochs and suddenly decreases to a certain value at some points.
We also have the cosine, cyclic, and warming up learning rate schedules to compare with, in addition to the staircase and piecewise linear one deployed to SEAT.
Figure 3a depicts the results of this experiment using various learning rate methodologies.
The natural accuracy under various learning rate schedules is reported by the top dashed lines, which all grow gradually over time.
After reaching their maxima, the relative bottom solid lines fall more or less.
Quantitative Results of above ﬁve strategies from best checkpoints are shown in Appendix A.3.
However, it can be observed that the red line (piecewise linear) and the blue line (cosine) decrease more slowly than the orange line (staircase) and they achieve higher robust accuracy at much later epochs than the staircase.
Apparently, the piecewise linear strategy makes τ approach the threshold τ t (cid:48) at a slow pace while the cosine one increases the valid candidate models that can make contributions.
Likewise, the cyclic strategy gets better robust accuracy and further improves the performance in the late stage.
But the effect of warming up learning rate is marginal since the homogenization of the candidate models we mentioned in Sec.
3.2 cannot be ﬁxed by the warmup strategy.
These facts bear out Proposition 2 from the side.
Epoch-based v.s. Iteration-based Ensembling.
Next, we investigate whether the frequency of ensembling has a great effect on the robustness of the collective.
Speciﬁcally, we select two scenarios to compare with.
One is an epoch-based ensemble that only gathers the updated models after traversing the whole training dataset.
The other is an iteration-based ensemble collecting models whenever SGD functions.
Comparison between the epoch-based and the iteration-based ensembling is shown in Figure 3b.
It can be seen that the curves of both two schemes are nearly the same in their prime except that the iteration-based method has a slightly greater natural accuracy and degrades more slowly.
Inﬂuence of the Initial Safeguard.
We also study the effect of the length of the initial safeguard.
We plot all results against different kinds of attacks with c ranging from 0 to 10000 (i.e. Epoch 32).
The curves in Figure 3c show that the model ensembled with large c , which ignores more history models, results in weaker memorization and poor robustness.
Actually, from the perspective of Proposition 2, t (cid:48) is ﬁxed if the scheme of learning rate updating and the total training epochs are unchanged.
So using a large c is equivalent to squeeze the number of benign candidates before t (cid:48) .
Similarly, a small c can manually ﬁlter the early models without being well trained.
However, such a drop is minor because EMA has a built-in mechanism for adjusting.
Mixed Strategies with SEAT for Improved Robustness.
Finally, we report the results under different mixed strategies on CIFAR-10 dataset with ResNet18 in Table 3.
Overall, SEAT+TRADES and
SEAT+TRADES+CutMix do not perform well.
We believe the reason is that TRADES cannot well adapt to learning strategies other than the staircase one for its history snapshots of TRADES trained under other strategies are much inferior than the ones trained under the staircase learning rate strategy.
However, MART is in harmony with other strategies.
The combination of SEAT+MART+CutMix achieves the best or the second-best robustness against almost all types of attacks.
[Table]
C ONCLUSION
In this paper
[Table]
we propose a simple but powerful method called Self-Ensemble Adversarial Training (SEAT), which unites states of every history model on the optimization trajectory through the process of adversarial training.
Compared with the standard ensemble method, SEAT only needs training once and has a better reusability.
Besides, we give a theoretical explanation of the difference between the above two ensemble methods and visualize the change of loss landscape caused by
SEAT.
Furthermore, we analyze a subtle but fatal intrinsic issue in the learning rate strategy for the self-ensemble model
[Table]
which causes the deterioration of the weight-ensembled method.
Extensive experiments validate the effectiveness of the proposed SEAT method.
A CKNOWLEDGEMENT
Yisen Wang is partially supported by the National Natural Science Foundation of China under Grant 62006153, Project 2020BD006 supported by PKU-Baidu Fund, and Open Research Projects of
Zhejiang Lab (No. 2022RC0AB05).
A F URTHER E XPERIMENTS
Here we adopt ResNet18 and / or WRN-32-10 as the backbone model with the same experimental setup as in Sec.
4.1, where we reported the natural accuracy (NAT), PGD-20 and PGD-100 attack (PGD), MIM (PGD with a momentum term), CW attack and each component of AutoAttack.
All the experiments are conducted for 5 individual trials and we also report their standard deviations.
All the methods were realized by Pytorch 1.5, where we used a single NVIDIA GeForce RTX 3090 GPU.
A. R OBUSTNESS AGAINST C OMPONENTS OF A UTO A TTACK
To broadly demonstrate the robustness of our proposal
[Table]
we conducted experiments against each component of AutoAttack.
We perform each component of AA on CIFAR-10 dataset with both
ResNet18 and WRN-32-10, including three parameter-free versions of PGD with the CE, DLR, targeted-CE loss with 9 target classes loss ( APGD CE , APGD DLR , APGD T ), the targeted version of FAB ( FAB T ) and an existing complementary Square (Andriushchenko et al., 2020).
Results are shown in the following Table 4.
And it is obvious that our SEAT outperforms other methods against all components of AA.
[Table]
A. P ERFORMANCE ON CIFAR-
To further demonstrate the robustness of our proposal against adversarial attacks
[Table]
we benchmark the state-of-the-art robustness with ResNet18 on CIFAR-100.
We widely investigate the performance of SEAT against the PGD methods ( PGD 20 and PGD 100 ), MIM, CW, AA and its all components.
Results shown in Table 5 demonstrate the effectiveness of SEAT for building a robust classiﬁer
[Table]
The maximum perturbation is ε = 8 / 255 .
Average accuracy rates (in %) and standard deviations have shown that the proposed SEAT method greatly improves the robustness of the model.
[Table]
A. D IFFERENT L EARNING R ATE S TRATEGIES
Apart from showing the curve of different learning rate schedule in Figure 3 (a) in Sec. 4.
[Table]
we also report ﬁnal results in Table 6.
The effect of warming up learning rate is marginal.
When compared with the staircase one, the warmup strategy cannot generate diverse models in the later stages so the homogenization of the candidate models we mentioned in Sec.
3.2 cannot be ﬁxed by the warmup strategy.
On the contrary, those methods like cosine / linear / cyclic that provide relatively diverse models in the later stages can mitigate the issue, accounting for more robust ensemble models
[Table]
A. D ETERIORATION OF VANILLA EMA
As shown in Sec. 3.
[Table]
the deteriorated SEAT underperforms SEAT a lot from the perspective of optimization.
We also report quantitative results on both ResNet18 and WRN-32-10 shown in the
[Table]
Tables 7 and 8.
The deteriorated one does not bring too much boost when compared to the vanilla adversarial training (except for PGD methods).
A plausible explanation for the exception of PGD is that the SEAT technique produces an ensemble of individuals that are adversarially trained by
PGD with the cross-entropy loss, which means that they are intrinsically good at defending the PGD attack with the cross-entropy loss and its variants even though they suffer from the deterioration.
Considering results have greatly improved after using the piecewise linear learning rate strategy, it is fair to say that adjusting learning rate is effective.
As we claimed in Proposition 2 and its proof, the staircase will inevitably make the self-ensemble model worsen since (cid:80)
Tt =1 ( β t ˜ ξ T ) will gradually approach to zero, meaning the difference between ¯ f F ( x, y ) and f ˜ θ ( x, y ) achieves the second order of smallness.
[Table]
[Table]
A. C OMPUTATIONAL C OMPLEXITY FOR SEAT
To demonstrate the efﬁciency of the SEAT method
[Table]
we use the number of Multiply-Accumulate operations (MACs) in Giga (G) to compute the theoretical amount of multiply-add operations in
DNNs, roughly GMACs = 0.5 * GFLOPs.
Besides, we also provide the actual running time.
As shown in Table
[Table]
the SEAT method takes negligible MACs and training time when compared with standard adversarial training.
[Table]
B P ROOFS OF THEORETICAL RESULTS B. P ROOF OF P ROPOSITION
Proposition 1.
(Restated)
Let f θ ( · ) denote the predictions of a neural network parametrized by weights θ .
Assuming that ∀ θ ∈ Θ , f θ ( · ) is continuous and ∀ ( x, y ) ∈ D , f θ ( x, y ) is at least twice differentiable.
Consider two points θ t , ˜ θ ∈ Θ in the weight space and let ξ = θ t − ˜ θ , for t ∈ { 1 , 2 , · · · , T } , the difference between ¯ f F ( x, y ) and f ˜ θ ( x, y ) is of the second order of smallness if and only if (cid:80)
Tt =1 ( β t ξ T )
= 0 .
Proof.
For the sake of the twice differentiability of f θ ( x, y ) , based on the Taylor expansion, we can ﬁt a quadratic polynomial of f ˜ θ ( x, y ) to approximate the value of f θ t ( x, y ) :
[Equation]
where O (∆ n ) represents the higher-order remainder term.
Note that the subscript ξ here stands for a neighborhood where the Taylor expansion approximates a function by polynomials of any point (i.e. ˜ θ ) in terms of its value and derivatives.
So the difference between the averaged prediction of candidate classiﬁers and the prediction of the ensembled weight classiﬁer can be formulated as:
[Equation]
Therefore, we can claim that the difference between f θ t ( x, y ) and f ˜ θ ( x, y ) is ”almost” at least of the ﬁrst order of smallness except for some special cases.
And we will immediately declare under which condition this difference can achieve the second order of smallness in the following proof of Theorem 1.
B. P ROOF OF T HEOREM
Theorem 1.
(Restated)
Assuming that for i, j ∈ { 1 , · · · , T } , θ i
= θ
j if and only if i = j .
The difference between the averaged prediction of multiple networks and the prediction of SEAT is of the second order of smallness if and only if β i =
(1 − α )
α i − 1 for i ∈ { 1 , 2 , · · · , T } .
Proof.
According to Eqn 11, we know that the second order of smallness will achieve when (cid:80)
[Equation]
1 ( β t ξ T ) = 0 .
Thus, we continue deducing from Eqn 11 as:
[Equation] [Equation]
To get a further aonclusion, we next use Mathematical Induction (MI) to prove only when β i =
(1 − α )
α i − 1 for i ∈ { 1 , 2 , · · · , T } will (cid:80)
Tt =1 β t θ t =
(cid:80) Tt =1 (1 − α )
α t − 1 θ t set up.
Base case: Let t = 1 , it is clearly true that β 1 = (1 − α )
α
if and only if β 1 θ 1 = (1 − α )
α 0 θ 1 , hence the base case holds.
Inductive step: Assume the induction hypothesis that for a particular k , the single case T = k holds, meaning the sequence of ( β 1 , β 2 , · · · , β k ) is equal to the sequence of ((1 − α )
α 0 , (1 − α )
α 1 , · · · , (1 − α )
α k − 1 ) if (cid:80) kt =1 β t θ t =
(cid:80) kt
=1 (
[Equation] [Equation]
t −
[Equation]
t .
For T = k + 1 , it follows that:
[Equation]
The sequence of normalized scores at the k + 1 -th ensembling at left hand is ( β 1 , β 2 , · · · , β k , β k +1 ) after adding the new term β k
+1 .
Likewise, the sequence of the right hand is ((1 − α )
α 0 , (1 − α )
α 1 , · · · , (1 − α )
α k − 1 , (1 − α ) α k ) .
Because every f θ t ∈ F is different from others and the sequence is ordered, we have ( β 1 , β 2 , · · · , β k , β k +1 )
=
((1 − α )
α 0 , (1 − α )
α 1 , · · · , (1 − α )
α k − 1 , (1 − α ) α k )
Conclusion: Since both the base case and the inductive step have been proved as true, by mathematical induction the statement β i = (1 − α )
α
i − 1 for i ∈ { 1 , 2 , · · · , T } holds for every positive integer
T .
Back to the starting point, the ﬁrst order term cannot be ignored in most cases.
SEAT is hardly be approximate to the averaged prediction of history networks indeed.
B. P ROOF OF P ROPOSITION
Proposition 2.
(Restated)
Assuming that every candidate classiﬁer is updated by SGD-like strategy, meaning θ t
+
=
θ t − τ t ∇ θ t f θ t ( x (cid:48) , y ) with τ 1 ≥ τ 2 ≥ · · · ≥ τ T > 0 , the self-ensemble model will inevitably worsen and the degree depends on learning rate schedules.
Proof.
First we discuss a special case - the change at the t -th iteration.
Reconsidering the ﬁrst order term in Eqn 11, we have:
[Equation]
Owing to the fact that the decay rate α close to 1 is typically recommended in practice, so 1 /α → 1 .
Then we can deduce by combining:
[Equation]
By using SGD to update θ t − 1 , we have:
[Equation]
Without changing samples in the t -th minibatch, we can conclude that the output of SEAT will be closer to the averaged prediction of multiple networks when the learning rate τ t becomes extremely small at the t -th iteration.
To further analyse the whole training process, we construct θ = 1 T (cid:80)
Tt =1 θ t and ˜ ξ
= θ − ˜ θ to unpack ˜ θ F\ t , and then reformulate Eqn 11:
[Equation]
When the learning rate τ t achieves the threshold where the updating amount becomes very small (as shown in Figure 1 (a) in the main body) at a certain iteration t (cid:48) , the learning rate schedules τ 1 ≥ τ 2 ≥ · · · ≥ τ T will be divided into τ 1 ≥ τ 2 ≥ · · · ≥ τ t (cid:48) and τ t (cid:48)
+1 ≥ τ t (cid:48)
+2 ≥ · · · ≥ τ T .
Because ( β 1 , β 2 , · · · , β T ) is a non-decreasing sequence, when T − t (cid:48)
→ ∞ , (cid:80) Tt =1 ( β t ˜ ξ T ) will gradually approach to zero, which means the difference between ¯ f F ( x, y ) and f ˜ θ ( x, y ) achieves the second order of smallness.