Stability Analysis and Generalization Bounds of Adversarial Training
Abstract
In adversarial machine learning, deep neural networks can fit the adversarial examples on the training dataset but have poor generalization ability on the test set.
This phenomenon is called robust overfitting, and it can be observed when adversarially training neural nets on common datasets, including SVHN, CIFAR-10,
CIFAR-100, and ImageNet.
In this paper, we study the robust overfitting issue of adversarial training by using tools from uniform stability.
One major challenge is that the outer function (as a maximization of the inner function) is nonsmooth, so the standard technique ( e.g., (Hardt et al., 2016)) cannot be applied.
Our approach is to consider η -approximate smoothness: we show that the outer function satisfies this modified smoothness assumption with η being a constant related to the adversarial perturbation ϵ .
Based on this, we derive stability-based generalization bounds for stochastic gradient descent (SGD) on the general class of η -approximate smooth functions, which covers the adversarial loss.
Our results suggest that robust test accuracy decreases in ϵ when T is large, with a speed between Ω( ϵ √ T ) and O ( ϵT ) .
This phenomenon is also observed in practice.
Additionally, we show that a few popular techniques for adversarial training ( e.g., early stopping, cyclic learning rate, and stochastic weight averaging) are stabilitypromoting in theory.
Introduction
[Figure]
Deep neural networks (DNNs) (Krizhevsky et al., 2012; Hochreiter and Schmidhuber, 1997) have become successful in many machine learning tasks and rarely suffered overfitting issues (Zhang et al., 2021).
A neural network model can be trained to achieve zero training error and generalize well to the unseen data.
While in the setting of adversarial training, robust overfitting is a dominant issue (Rice et al., 2020).
Specifically, robust overfitting characterizes a training procedure shown in Fig.
After a particular epoch, the robust test accuracy (black line) starts to decrease, but the robust training accuracy (blue line) is still increasing.
This phenomenon can be observed in the experiments on common datasets, e.g., SVHN,
CIFAR-10, CIFAR-100, and ImageNet.
Recent works (Gowal et al., 2020; Rebuffi et al., 2021) mitigated the overfitting issue using regularization techniques such as stochastic weight averaging (SWA) and early stopping, but it still has a large generalization gap.
Therefore, it is essential to study this issue from a theoretical perspective.
In this paper, we study the robust overfitting issue of adversarial training by using tools from uniform stability.
Uniform stability analysis (Bousquet and Elisseeff, 2002) in learning problems has been introduced to measure generalization gap instead of uniform convergence analysis such as classical VCdimension (Vapnik and Chervonenkis, 2015) and Rademacher complexity (Bartlett and Mendelson, 2002).
Generalization gap can be bounded in terms of uniform argument stability (UAS).
Formally,
UAS is the gap between the output parameters θ of running an algorithm A on two datasets S and
S ′ differ in at most one sample, denoted as δ ( S, S ′ )
=
∥ θ ( S ) − θ ( S ′ )
∥ .
In a standard training problem with n training samples, assuming that the loss function is convex, L -Lipschitz and β -gradient
Lipschitz, running stochastic gradient descent (SGD) with step size α ≤ 1 /β for T steps, the UAS is bounded by O ( LαT/n ) (Hardt et al., 2016).
Since the generalization gap is controlled by the number of samples n , this bound (at least partially) explains the good generalization of a standard training problem.
Beyond (Hardt et al., 2016), Bassily et al.
(2020) considered the case that the loss function is non-smooth.
Without the β -gradient Lipschitz assumption, they showed that the
UAS is bounded by O ( Lα √ T + LαT/n ) and provided a lower bound to show that the additional term O ( Lα √ T ) is unavoidable.
In adversarial settings, two works have discussed the stability of adversarial training to our knowledge.
Firstly, Farnia and Ozdaglar (2021) considered the stability of minimax problems.
Their work includes a discussion on an algorithm called GDmax (gradient descent on the maximization of the inner problem), which can be viewed as a general form of adversarial training.
It provides the stability of GDmax when the inner problem is further assumed to be strongly concave.
Under the strongly concave assumption, the outer function is smooth.
Then, the generalization bound O ( LαT/n ) can be applied in this case.
However, the inner problem is not strongly concave in practice.
The bound
O ( LαT/n ) does not match the poor generalization of adversarial training observed in practice.
Another stability analysis of adversarial training is the work of (Xing et al., 2021a).
Before they propose their algorithm, they use the stability bound
O
( Lα √ T + LαT/n ) (Bassily et al., 2020)
to characterize the issue of adversarial generalization.
However, the bound is ϵ -independent.
Let us Consider two cases, ϵ → 0 and ϵ is large ( e.g., 16/255).
In the first case, adversarial training is very close to standard training and has good generalization ability.
In the second case, adversarial generalization is very poor.
The bound is the same in these two different cases.
Therefore, it cannot provide an interpretation of adversarial generalization.
In summary, existing stability-based generalization bounds (Hardt et al., 2016; Bassily et al., 2020) have limited interpretation on adversarial generalization.
In this paper, we provide a new stability analysis of adversarial training using the notion of η -approximate smoothness.
We first show that, under the same assumptions as (Hardt et al., 2016; Xing et al., 2021a), even though the outer function (adversarial loss) is non-smooth, it is η -approximately smooth (see Definition 4.1), where η is a constant linearly depending on the gradient Lipschitz of the inner function and the perturbation intensity ϵ .
Then, we derive stability-based generalization bounds (Thm. 5.1 to 5.4) for stochastic gradient descent (SGD) on this general class of η -approximate smooth functions, which covers the adversarial loss.
Our main result can be summarized in the following equation.
Running SGD on adversarial loss for T steps with step size α ≤ 1 /β , the excess risk, which is the sum of generalization error and optimization error, satisfies
[Equation]
The excess risk of adversarial training has an additional term LηTα .
We also provide a lower bound of UAS of running SGD on adversarial loss.
Our results suggest that robust test accuracy decreases in ϵ when T is large, with a speed between Ω( ϵ √ T ) and O ( ϵT ) .
This phenomenon is also observed in practice.
It provides an understanding of robust overfitting from the perspective of uniform stability.
Additionally, we show that a few popular techniques for adversarial training ( e.g., early stopping, cyclic learning rate, and stochastic weight averaging) are stability-promoting in theory and also empirically improve adversarial training.
Experiments on SVHN, CIFAR-10,
CIFAR-100, and ImageNet confirm our results.
Our contributions are listed as follows:
• Main results: we derive stability-based generalization bounds for adversarial training using the notion of η -approximate smoothness.
Based on this, we provide an analysis to understand robust overfitting.
• We provide the stability analysis of a few popular techniques for adversarial training and show that they are indeed stability-promoting.
• We provide experiments on SVHN, CIFAR-10, CIFAR-100, and ImageNet.
The results verify the generalization bounds.
• Technical contribution: we develop a set of properties of η -approximately smooth function, which might be useful in other tasks.
The paper is organized as follows.
After discussing the related work in Sec. 2, the rest of the paper contains two parts.
The first part is the technical part to derive stability bounds.
The second part is to analyze robust overfitting.
Specifically, in the first part, Sec. 3 introduces the preliminary knowledge about UAS.
Sec. 4 provides the Lemma and properties of approximately smooth functions and Sec.gives the stability bounds.
In the second part, Sec. 6 analyzes the robust overfitting in the theoretical settings and Sec.
7 presents the experiments.
Related Work
Adversarial Attacks and Defense.
Starting from the work of (Szegedy et al., 2013), it has been commonly realized that deep neural networks are highly susceptible to imperceptible corruptions to the input data (Goodfellow et al., 2014; Carlini and Wagner, 2017; Madry et al., 2017).
A series of work aimed at training neural networks robust to such small perturbations (Wu et al., 2020;
Gowal et al., 2020; Zhang et al., 2020) and another line of work aimed at designing more powerful adversarial attack algorithms (Athalye et al., 2018; Tramer et al., 2020; Fan et al., 2020; Xiao et al., 2022c;
Qin et al., 2022).
A series of work considered adversarial robustness in black-box settings (Chen et al., 2017; Qin et al., 2021).
Semi-supervised learning has been used to improve adversarial robustness (Carmon et al., 2019; Li et al., 2022).
Fast adversarial training (Wong et al., 2020; Huang et al., 2022) was introduced to save training time.
Adversarial Generalization.
A series of work tried to explain adversarial generalization in the uniform convergence framework, including VC-dimension (Attias et al., 2021;
Montasser et al., 2019) and Rademacher complexity (Khim and Loh, 2018;
Yin et al., 2019; Awasthi et al., 2020; Xiao et al., 2022a).
Uniform algorithmic stability is another framework to study adversarial generalization (Farnia and Ozdaglar, 2021; Xing et al., 2021a; Xiao et al., 2022b).
The work of (Schmidt et al., 2018; Raghunathan et al., 2019; Zhai et al., 2019) have shown that in some scenarios achieving adversarial generalization requires more data.
The work of (Xing et al., 2021b,c; Javanmard et al., 2020) studied the generalization in the setting of adversarial linear regression.
(Sinha et al., 2017) studied the generalization of distributional robustness.
The work of (Taheri et al., 2020; Javanmard et al., 2020; Dan et al., 2020) analyzed adversarial generalization in Gaussian mixture models.
Uniform Stability.
Stability is a classical approach to provide generalization bounds.
It can be traced back to the work of (Rogers and Wagner, 1978).
After a few decades, it was well developed in analyzing the generalization bounds in statistical learning problems (Bousquet and Elisseeff, 2002).
These bounds have been significantly improved in a recent sequence of works (Feldman and
Vondrak, 2018, 2019).
The work of (Chen et al., 2018) derived minimax lower bounds for excess risk and discussed the optimal trade-off between stability and convergence.
Ozdaglar et al.
(2022) considered the generalization metric of minimax optimizer.
Preliminaries of Stability
Consider the following setting of statistical learning.
There is an unknown distribution D over examples from some space Z .
We receive a sample dataset S
= { z 1 , . . .
, z n } of n examples drawn i.i.d.
from D .
The population risk and empirical risk are defined as:
[Equation]
R S
[Equation]
θ ) def
[Equation]
1 n n
[Equation]
i
[Equation]
h ( θ
[Equation]
z i ) , respectively, where h ( · , · ) is the loss function.
Risk Decomposition.
Let θ ∗ and ¯ θ be the optimal solution of R D ( θ ) and R S ( θ ) respectively.
Then for the algorithm output ˆ θ =
A ( S ) , the excess risk can be decomposed as
[Equation]
To control the excess risk, we need to control the generalization gap E gen and the optimization gap
E opt .
In the rest of the paper, we use E gen and E opt to denote the expectation of the generalization and optimization gap.
To bound the generalization gap of a model ˆ θ =
A ( S ) trained by a randomized algorithm A , we employ the following notion of uniform stability .
Definition 3.1.
A randomized algorithm A is ε - uniformly stable if for all data sets S, S
′ ∈
Z n such that S and S ′ differ in at most one example, we have
[Equation]
Here, the expectation is taken only over the internal randomness of A .
We recall the important theorem that uniform stability implies generalization in expectation (Hardt et al., 2016).
Theorem 3.1 (Generalization in expectation) .
Let A be ε -uniformly
stable.
Then, the expected generalization gap satisfies
[Equation]
≤ ε .
Therefore, we turn to the properties of iterative algorithms that control their uniform stability.
Stability of Adversarial Training
Adversarial Surrogate Loss.
In adversarial training, we consider the following surrogate loss
[Equation]
where g ( θ ; z ) is the loss function of the standard counterpart, ∥·∥ p is the ℓ p -norm, p ≥ 1 .
Usually, g can also be written in the form of ℓ ( f θ ( x ); y ) , where f θ is the neural network to be trained and ( x , y ) is the input-label pair.
We assume the loss function g satisfies the following smoothness assumption.
Assumption 4.1.
The function g satisfies the following Lipschitzian smoothness conditions:
[Equation]
where ∥ · ∥ is Euclidean norm.
Assumption 4.1 assumes that the loss function is smooth, which are also used in the stability literature (Farnia and Ozdaglar, 2021;
Xing et al., 2021a), as well as the convergence analysis literature (Wang et al., 2019; Liu et al., 2020).
While ReLU activation function is non-smooth, recent works (Allen-Zhu et al., 2019; Du et al., 2019) showed that the loss function of over-parameterized DNNs is semi-smooth.
It helps justify Assumption 4.1.
Under Assumption 4.1, the loss function of adversarial training satisfies the following Lemma (Liu et al., 2020).
Lemma 4.1.
Let h be the adversarial loss defined in Eq.
(4.1) and g satisfies Assumption 4.1.
∀ θ 1 , θ 2 and ∀ z ∈ Z , the following properties hold.
(Lipschitz function.)
∥
h ( θ 1 , z ) − h ( θ 2 , z ) ∥
≤ L ∥ θ 1 − θ 2 ∥ .
For all subgradient d ( θ, z ) ∈ ∂ θ h ( θ, z ) , we have ∥ d ( θ 1 , z ) − d
θ 2 , z ) ∥
≤ L θ ∥ θ 1 − θ 2 ∥ + 2 L z ϵ .
If we further assume that g ( θ, z ) is µ -strongly concave in z , the adversarial surrogate loss h ( θ, z ) is also smooth (Sinha et al., 2017).
Therefore, the uniform stability of adversarial training follows (Hardt et al., 2016; Farnia and Ozdaglar, 2021), see Appendix B.3.
However, g ( θ, z ) is non-strongly concave in practice.
The above results provide limited explanations of the poor generalization of adversarial training.
We discuss the generalization properties of adversarial training under Lemma 4.1.2.
4.1 Basic Properties of Approximate Smoothness
To simplify the notation, we use h ( θ ) as a shorthand notation of h ( θ, z ) .
To simplify the argument, we consider differentiable function h .
The results can be extended to non-differentiable cases.
Lemma 4.1 motivates us to analyze a function with the following modified smoothness assumption, which we call approximate smoothness assumption.
Definition 4.1.
Let β > 0 and η > 0 .
We say a differentiable function h ( θ ) is η -approximately β -gradient Lipschitz, if ∀ θ 1 and θ 2 , we have
[Equation]
In definition 4.1, η controls the smoothness of the loss function h ( · ) .
When η = 0 , the function h is gradient Lipschitz.
When η → + ∞ , h is a general non-smooth function.
As our discussion before, the adversarial surrogate loss is 2 L z ϵ -approximately smooth.
As far as we know, this assumption is rarely discussed in the optimization literature since it cannot improve the convergence rate from a general non-smooth assumption.
But it affects uniform stability, as we will discuss later.
We need to develop the basic properties of approximate smoothness first.
Lemma 4.2.
Assume that the function h is η -approximately β -gradient Lipschitz.
∀ θ 1 , θ 2 and ∀ z ∈
Z , the following properties hold.
( η -approximate descent lemma.)
[Equation]
( η -approximately co-coercive.)
Assume in addition that h ( θ, z ) is convex in θ for all z ∈ Z .
Let [ · ] + = max(0 , · ) .
We have
[Equation]
We defer the proof to Appendix A. Note that the loss function is L -Lipschitz for every example z , we have E | h ( θ 1 , z ) − h ( θ 2 , z ) | ≤ L E ∥
θ 1 − θ 2 ∥ , for all z ∈ Z .
To obtain the stability generalization bounds, we need to analysis the difference ∥ θ T 1 − θ T 2 ∥ , where θ T 1 and θ T 2 are the outputs of running
SGD on adversarial surrogate loss for T iterations on two datasets with only one different sample.
Next we provide the recursive bounds under the approximate smoothness assumption.
Algorithms.
We consider the stochastic gradient descent on the adversarial surrogate loss.
i.e.,
[Equation]
where α t is the step size in iteration t , z i t is the sample chosen in iteration t .
We consider two popular schemes for choosing the examples indices i t .
Sampling with replacement : One is to pick i t ∼ Uniform { 1 , · · · , n } at each step.
Fixed permutation : The other is to choose a random permutation over { 1 , · · · , n } and cycle through the examples repeatedly in the order determined by the permutation.
Our results hold for both variants.
Properties of Update Rules.
We define G α,z ( θ ) =
θ − α ∇ h ( θ, z ) be the update rule of SGD.
The following lemma holds.
Lemma 4.3.
Assume that the function h is η -approximately β -gradient Lipschitz.
∀ θ 1 , θ 2 and ∀ z ∈
Z ,we have 1.
( αη -approximately (1 + αβ ) -expansive.)
∥ G α,z ( θ 1 ) − G α,z ( θ 2 ) ∥ ≤ (1 + αβ ) ∥ θ 1 − θ 2 ∥ + αη.
( αη -approximately non-expansive.)
Assume in addition that h ( θ, z ) is convex in θ for all z ∈ Z , for α ≤ 1 /β , we have ∥ G α,z ( θ 1 ) − G α,z
( θ ∥ ≤ ∥ θ 1 − θ 2 ∥ + αη.
( αη -approximately (1 − αγ ) -contractive.)
Assume in addition that h ( θ, z ) is γ -strongly convex in θ for all z ∈ Z , for α ≤ 1 /β , we have ∥ G α,z ( θ 1 ) − G α,z ( θ 2 ) ∥ ≤ (1 − αγ )
∥ θ 1 − θ 2 ∥ + αη.
The proof of Lemma 4.3 is based on Lemma 4.2 and is deferred to Appendix A. Lemma 4.3 provides the recursive distance ∥ θ 1 − θ 2 ∥ from iteration t to t + 1 .
Based on this, we can recursively derive the distance ∥ θ T 1 − θ T 2 ∥ .
Then, we can obtain the stability generalization bounds.
Stability Generalization Bounds
In the previous section, we have discussed the properties of approximate smoothness and developed tools we need to use.
In this section, we discuss the stability bounds.
5.1 Convex Optimization
We first consider the case that h ( θ, z ) is convex in θ for all z ∈ Z .
Theorem 5.1.
Assume that h ( θ, z ) is convex, L -Lipschitz, and η -approximately β -gradient Lipschitz in θ for all given z ∈ Z .
Suppose that we run SGD with step sizes α t ≤ 1 /β for T steps.
Then,
[Equation]
The proof is mainly based on Lemma 4.3 that the update rule is approximately non-expansive in this case.
We defer it to appendix A. We have shown that the adversarial surrogate loss is 2 L z ϵapproximately L θ -gradient Lipschitz.
Let η = 2 L z ϵ in Eq.
(5.1), we directly obtain the stability bounds for adversarial training.
In practice, the solution of the inner problem is sub-optimal.
Let ∆ ϵ be the maximum error between the optimal and sub-optimal attacks in each iteration.
We have the following Corollary.
Corollary 5.1 (Uniform stability for sub-optimal attacks adversarial training.) .
Under Assumption 4.1, assume in addition that g ( θ, z ) is convex in θ for all given z ∈ Z .
Suppose that we run adversarial training with step sizes α t ≤ 1 /L θ for T steps.
Then, adversarial training satisfies uniform stability with
[Equation]
Remark:
Corollary 5.1 shows that adversarial training with weak attacks (large ∆ ϵ ) have worse adversarial generalization than that with strong attacks.
This is also observed in practice.
However, ∆ ϵ is at most 2 ϵ , the upper bound of AT with different attacks have the same order.
It might be due to the weakness of Assumption 4.1 or uniform stabilty framework.
Interpreting Robust Generalization.
If we let ϵ = 0 in Eq.
(5.2) , it reduced to the generalization bound in (Hardt et al., 2016) for standard training.
Therefore, the additional generalization error of adversarial training comes from the additional term L z ϵ .
The global gradient Lipschitz L z with respect to z plays an important role in generalization.
Even though the perturbation ϵ is small, it is amplified by the Lipschitz L z and finally hurts the robust generalization.
5.2 Further Discussion on the Generalization Bounds
We first provide a lower bound.
Then we compare our bounds with the existing bounds in Table 1.
Theorem 5.2 (Lower Bound) .
There exists functions h ( θ, z ) , s.t.
h is convex, L -Lipschitz, and ηapproximately β -gradient Lipschitz
in θ for all given z ∈ Z .
Exists S and S ′ differ in one sample.
Suppose that we run SGD with step fixed step sizes α ≤ 1 /β for T steps.
Then,
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
Comparison with the Existing UAS Bounds.
Compared with the work of (Farnia and Ozdaglar, 2021), they assume that the inner problem is strongly concave.
Thus the bounds are not comparable.
Strongly concave is a strong assumption in practice.
Therefore, the work of (Xing et al., 2021a) and our analysis focus on the nonconcave cases.
Comparing with the bound O ( L √ Tα + LTα/n ) , our bound captures a critical aspect of adversarial generalization bound: ϵ -dependent.
As observed in practice, the adversarial generalization gap reduces to the standard generalization gap as ϵ → 0 .
Our bound consists with this observation.
On the contrary, the bound O ( L √ Tα + LTα/n ) is very large when ϵ → 0 .
Additionally, we provide a matching lower bound w.r.t η .
The comparison is provided in Table 1.
Comparison with the Work of (Xing et al., 2021a).
The work of (Xing et al., 2021a) argued that the max function is not smooth even though the standard counterpart is smooth.
Therefore, they followed the bound in non-smooth cases (Bassily et al., 2020).
Then, they aimed to solve the non-smooth issue.
They design a noise-injected algorithm and show its effectiveness in tackling the non-smooth issue.
Our work focus on providing better bounds to interpret robust overfitting.
5.3 Non-convex Optimization and Strongly Convex Optimization
Next, we consider the case that the loss function h is general non-convex and strongly convex.
By
Lemma 4.3, we have
Theorem 5.3.
Assume that h ( θ, z ) is L -Lipschitz, and η -approximately β -gradient Lipschitz in θ for all given z ∈ Z .
Assume in addition that 0 ≤ h ( θ, z ) ≤ B for all θ and z .
Suppose that we run
SGD with diminishing step sizes α t ≤ 1 / ( βt ) for T steps.
Then
[Equation]
Theorem 5.4.
Assume that h ( θ, z ) is γ -strongly convex, L -Lipschitz, and η -approximately βgradient Lipschitz in θ for all given z ∈ Z .
Suppose that we run SGD with step sizes α t ≤ 1 /β for
T steps.
Then
[Equation]
Remark:
The bound in non-convex cases provides a similar interpretation of robust generalization to the analysis in the convex case.
In uniform stability analysis, whether the loss function is convex or non-convex does not give a major difference.
Therefore, we provide the analysis of the non-convex case in Appendix B. We also provide our convergence analysis of running SGD on a η -approximate smoothness, non-convex function in Theorem B.1.
Strongly convex is a strong assumption. We leave the analysis of the bound in strongly convex cases in Appendix B.2.
Excess Risk Minimization
Based on the risk decomposition, we have Excess Risk ≤ E gen + E opt , we need to minimize E gen +
E opt to achieve better performance.
Per our previous discussion, whether the loss function is convex or non-convex does not give a major difference in stability analysis.
We study the convex case in this section.
We leave the discussion on the non-convex and strongly convex cases in Appendix B. and B.2, respectively.
We first introduce the optimization error.
Optimization Analysis.
The convergence analysis of SGD on a L -Lipschitz, convex function is discussed in (Nemirovski et al., 2009).
The convergence rate cannot be improved if we further assume that the function h is gradient Lipschitz.
Therefore, a weaker condition, approximately gradient Lipschitz, cannot improve the convergence rate.
We use the following convergence error bound (adopted from (Nemirovski et al., 2009)) for the optimization error of both adversarial training and standard training.
Theorem 6.1.
Assume that h ( θ, z ) is L-Lipschitz and convex in θ for all given z ∈ Z .
Let D =
∥ θ 0 − θ ∗ ∥ , where θ 0 is the initialization of SGD.
Suppose that we run SGD with step sizes α t for T steps.
Then, ∃ k ≤ T , s.t.
[Equation]
[Equation]
If we let α t = 1 / √ T , we have E opt ≤ O (1 / √ T ) , which is the convergence rate of SGD on convex function.
Since we need to consider the generalization and optimization errors simultaneously, we keep the α t in Theorem 6.1.
Generalization-Optimization Trade-off.
We have now discussed the optimization and generalization errors of adversarial training.
We aim to find the optimal trade-off between generalization and optimization in terms of α t and T .
However, finding the optimal α t and T simultaneously is challenging.
We consider the settings we use in practice.
Fixed Step Size.
We first consider the simplest case, the step size α is fixed.
Then, combining Eq.
(5.1) and Eq.
(6.1), we have
[Equation]
Interpretation of Robust Overfitting.
In standard training, overfitting is rarely observed in practice.
The optimization error and generalization error are both small.
In Eq.
(6.2), the second to the fourth terms are for standard training.
The second term is controlled by the number of samples n , which is small if we have sufficient training samples.
The third term is controlled by T , and the last term is fixed given a small α .
This bound partially explains the good performance of standard training.
However, we have an additional term LηTα for excess risk in adversarial training.
Then, after a particular iteration that LηTα dominates Eq.
(6.2), robust overfitting appears.
This is consistent with the training procedure in practice.
Therefore, the η = 2 L z ϵ approximate smoothness of adversarial loss provides a possible explanation of robust overfitting.
To achieve better performance, we need to stop training the model earlier.
Early Stopping.
It is shown that early stopping is an important training technique for adversarial training (Rice et al., 2020).
In Eq.
(6.2), if we optimize the right-hand-side with respect to T , we have
[Equation]
Therefore, it is the best to stop training at T ∗ .
However, T ∗ is unknown in practice.
It is important to select stopping criteria.
For example, we can use a validation set to determine when to stop.
Varying Step Size.
We discuss one popular varying step size schedule, cyclic learning rate, which is also called super-converge learning rate for adversarial training.
It is shown that it can speed up adversarial training with fewer epochs (Wong et al., 2020).
The Super-converge learning rate follows the following rules.
In the first phase (warm-up), the step size increase from 0 to α ′ linearly.
In the second phase (cold down), the step size decreases back to 0 linearly.
It is unclear (to our knowledge) why this schedule can speed up convergence in optimization theory.
But the generalization part can partially be explained by UAS.
If we set α ′ =
2 α , it is easy to check that E gen ≤ ( Lη + 2 L 2 /n )
Tα in this case, which is the same as the bound in the fixed learning rate case.
Notice that the cyclic learning rate usually requires fewer steps T to converge.
Then, the generalization gap is smaller.
Cyclic learning rate can be viewed as another form of early stopping from the perspective of UAS.
Stochastic Weight Averaging.
SWA is also a useful training technique for adversarial training (Hwang et al., 2021).
Instead of using the last checkpoint, SWA suggests using the average of the checkpoints for inference.
It is shown that SWA can find a model with better generalization since it leads to wider minima (Izmailov et al., 2018).
Below we study SWA from the perspective of UAS.
Theorem 6.2.
Assume that h ( θ, z ) is convex, L -Lipschitz, and η -approximately β -gradient Lipschitz in θ for all given z ∈ Z .
Suppose that we run SGD with step sizes α t ≤ 1 /β for T steps.
Let ¯ θ be the average of the trajectory.
Then,
[Equation]
In words, SWA reduces the generalization error bound to one-half of the one without SWA.
But the training error bound remains unchanged.
Experiments
Training Settings.
We mainly consider the experiments on CIFAR-10 (Krizhevsky et al., 2009),
CIFAR-100, and SVHN (Netzer et al., 2011).
We also provide one experiment on ImageNet (Deng et al., 2009).
For the first three datasets, we conduct the experiments on training PreActResNet-18, which follows (Rice et al., 2020), For the experiment on ImageNet, we use ResNet-50 (He et al., 2016), following the experiment of (Madry et al., 2017).
For the inner problems, we adopt the ℓ ∞
PGD adversarial training in (Madry et al., 2017), the step size in the inner maximization is set to be ϵ/ 4 on CIFAR-10 and CIFAR100 and is set to be ϵ/ 8 on SVHN.
Weight decay is set to be 5 × 10 − 4 .
Additional experiments are provided in Appendix C.
[Figure]
Robust Overfitting on Common Dataset.
In Fig.
2 (a), (b) [Figure] and (c), we show the experiments on the piece-wise learning rate schedule, which is 0.1 over the first 100 epochs, down to 0.01 over the following 50 epochs, and finally be 0.001 in the last 50 epochs, on CIFAR-10, CIFAR- [Figure]
and
SVHN.
Experiments on different ϵ are shown in Appendix C. Robust Overfitting on ImageNet.
We provide one experiment on ImageNet in Fig.
2 (d).
We start from a pre-trained model from Madry’s
Lab and keep running 50 more epochs.
Robust overfitting can be observed in these experiments.
After a particular epoch (around the 100 th epoch) [Figure] the robust training accuracy is still increasing, but the robust test accuracy starts to decrease
[Figure]
Fixed Step Size.
To better understand robust overfitting and match the theoretical settings (in
Eq.
, we consider the fixed learning rate schedule.
In Fig.
3, we show the experiments of adversarial training using a fixed learning rate 0 .
The perturbation intensity ϵ is set to be 2, 4, 6, 8, and 10. respectively.
Fig.
3 (a) and (b) show the experiments on CIFAR-10.
Fig.
3 (c) and (d) show the experiments on CIFAR-100, respectively.
Fig.
4 shows the experiments on SVHN.
[Figure]
Generalization Error Dominates Training
Error.
In the robust overfitting phase, the robust generalization error dominates the robust training error.
This phenomenon corresponds to the Eq.
(6.2) that the first term dominates the other terms with large T .
Robust Test Accuracy Decreases in ϵ .
Comparing different ϵ in Fig.
3, we can see that the robust test accuracy decreases faster when ϵ is larger.
This corresponds to the robust overfitting rule in the theoretical setting that the test performance decreases in ϵ .
These phenomena are similar in theoretical and practical settings.
Therefore, the stability analysis provides a different perspective on understanding robust overfitting.
Robust Test Accuracy Decreases in a Rate between Ω( ϵ √ T ) and O ( ϵT ) .
If ϵ is small, e.g., ϵ = 2 , the decrease rate is close to O ( ϵT ) .
If ϵ is large, the decrease rate is more likely to be Ω( ϵ √ T ) .
This is also the gap between the upper bound and lower bound in Sec. 5.
Conclusion
Limitations and Future Work.
Firstly, in Fig.
3, we can see that the decrease rate of robust overfitting is close to O ( T ) when ϵ is small and is close to Ω( √ T ) when ϵ is large.
One possible direction is to figure out the relation.
Secondly, one might improve adversarial training by controlling L z .
L z depends on the loss, the network architecture, and the dataset.
One possible direction is to design a smoother loss or smooth activation function (e.g., SiLU) for a lower L z .
Notice that L z is uniform for all θ .
If we view L z ( θ ) locally with respect to θ , we might use an (approximated) second-order penalty term on its magnitude to control it.
In this paper, we show that the adversarial loss satisfies η -approximate smoothness, and we derive stability-based generalization bounds on this general class of η -approximate smooth functions.
Our bounds give a different perspective on understanding robust overfitting.
The robust test accuracy decreases in η , and experimental results confirm this phenomenon.
We think our work will inspire more theoretical and empirical research to improve adversarial training.
Acknowledgement
We would like to thank Jiawei Zhang, Congliang Chen, and Zeyu Qin for the helpful discussions.
We thank all the anonymous reviewers for their comments and suggestions.
The work of Zhi-Quan Luo is supported by the National Natural Science Foundation of China (No. 61731018) and the
Guangdong Provincial Key Laboratory of Big Data Computing.
A Proof of the Theorem A.1 Proof of Theorem 3.
The proof can be found in (Hardt et al., 2016).
We provide the proof in Appendix for reference.
Denote by S =
( z 1 , . . .
, z n ) and S ′ =
( z ′ 1 , . . .
, z ′ n ) two independent random samples and let S ( i ) =
( z 1 , . . .
, z i − 1 , z ′
i , z i +1 , . . .
, z n ) be the sample that is identical to S except in the i ’th example where we replace z i with z ′ i .
With this notation, we get that
[Equation]
where we can express δ as
[Equation]
Furthermore, taking the supremum over any two data sets S, S ′ differing in only one sample, we can bound the difference as
[Equation]
by our assumption on the uniform stability of A.
The claim follows.
□
A.2 Proof of Lemma 4.
Let the adversarial examples for parameter θ
and θ 2 be
[Equation]
then we have
[Equation]
where the first inequality is based on the fact that g ( θ 1 , z 1 ) ≥ g ( θ 1 , z 2 ) and g ( θ 2 , z 2 ) ≥ g ( θ 2 , z 1 ) , the second inequality is based on Assumption 4.1.
This proves Lemma 4.1.1.
For all subgradient d ( θ, z ) ∈ ∂ θ h ( θ, z ) , we have
[Equation]
where the first and the third inequality is due to triangle inequality, the second inequality is based on
Assumption 4.1.
This proves the second inequality (non-gradient Lipschitz) in Lemma 4.1.
□
A.3 Proof of Lemma 4.
Proof of Lemma 4.2.1 ( η -approximate descent Lemma).
Let ˜ θ be a point in the line segment of θ 1 and θ 2 , ˜ θ ( u )
= θ 2 + u ( θ 1 − θ 2 ) , then
[Equation]
□
Proof of Lemma 4.2.2 ( η -approximate co-coercive).
By Lemma 4.2.1 ( η -approximate descent Lemma), we have
[Equation]
Let θ ∗ be a minimizer of h , then
[Equation]
where t = ∥ θ 1 − θ 2 ∥ and v = ( θ 1 − θ 2 ) /
∥ θ 1 − θ 2 ∥ .
Then
[Equation]
If ∥∇ θ h ( θ 2 ) ∥ − η ≤ 0 , the quaduatic function is optimized when t = 0 .
Then
[Equation]
= h ( θ
[Equation] [Equation]
If ∥∇ θ h ( θ 2 ) ∥ − η ≥ 0 , then
[Equation]
Therefore, we obtain that
[Equation]
Define
[Equation]
and
[Equation]
Firstly, it is easy to see that
h 1 ( w ) and h 2 ( w ) are both η -approximate β -gradient Lipschitz, which satisfies inequatily in Eq.
(A.1).
Secondly, w = θ 1 minimizes h 1 ( w ) .
Then
[Equation]
Similarly
[Equation]
we have
[Equation]
Take the summation of Eq.
(A.2) and Eq.
(A.3)
[Equation]
we have
[Equation]
A.4 Proof of Lemma 4.
Proof of Lemma 4.3.1 ( αη -approximately (1 + αβ ) -expansive).
[Equation]
□
Proof of Lemma 4.3.2 ( αη -approximately non-expansive.)
Let t
=
∥∇ h ( θ 1 ) − ∇ h
( θ 2 ) ∥ .
If t ≤ η , we have
[Equation]
If t ≥ η , we have
[Equation]
Let α ≤ 1 /β
[Equation]
then
[Equation]
By the definition of η -approximate smoothness
[Equation]
Then
[Equation]
Therefore, we obtain that
[Equation]
□
Proof of Lemma 4.3.3 ( αη -approximately (1 − αγ ) -contraction.).
Firstly, if h ( θ ) is a γ -strongly convex, η -approximately β -gradient Lipschitz function, ϕ ( θ )
= h ( θ ) − γ
∥ θ ∥ 2 is a convex, η -approximate ( β − γ ) -gradient Lipschitz function.
The proof of convexity follows the definition.
To see the second claim, since
[Equation]
≤⟨∇
[Equation]
≤⟨∇
[Equation]
≤⟨∇
[Equation]
Therefore, ϕ ( θ ) satisfies the η -approximate ( β − γ ) -descent
Lemma.
Let t = ∥∇ ϕ
( θ 1 ) − ∇ ϕ ( θ 2 ) ∥ .
If t ≤ η , we have
[Equation]
If t ≥ η , we have
[Equation]
Since α ≤ 1 /β
[Equation]
we have (1 − αγ ) / ( β − γ ) ≥ α , then
[Equation]
[Table]
Therefore, we obtain that
[Equation]
□
A.5 Proof of Theorem 5.
The proof follows the standard techniques for uniform stability.
We need to replace the nonexpansive property used in standard analysis by the approximately non-expansive property.
Let
S and S ′ be two samples of size n differing in only a single example.
Consider two trajectories θ 11 , . .
, θ T 1 and θ 12 , . .
, θ T 2 induced by running SGD on sample S and S ′ , respectively.
Let δ t =
∥
θ t 1 − θ t 2 ∥ .
Fixing an example z ∈ Z and apply the Lipschitz condition on h ( · ; z ) , we have
[Equation]
Observe that at step t, with probability 1 − 1 /n, the example selected by SGD is the same in both
S and S ′ .
With probability 1 /n the selected example is different.
Therefore, by the αη -approximate non-expansive property, we have
[Equation]
Unraveling the recursion gives
[Equation]
Plugging this back into Eq.
(A.4), we obtain
[Equation]
Since this bounds holds for all S, S ′ and z, we obtain the desired bound on the uniform stability.
□
A.6 Proof of Theorem 5.
Proof: The construction of function h is adopted from the construction in the work of (Bassily et al., 2020).
Let T ≤ d , and v, K ≥ 0 .
Considering Z = { 0 , 1 } , and the objective function
[Equation]
where r = ( − 1 , · · · , − 1 , 0 , · · · , 0) (i.e., equals to -1 for the first T components).
Function h is η -approximately smooth since the first case is a piece-wise linear function.
For the dataset S and S ′ differ in at most one sample, the empirical objective functions are
[Equation]
and
[Equation]
Let θ T 1 and θ T 2 be the trajectories running algorithm on dataset S and S ′ , initialized on θ
= θ 02 = 0 .
Clearly, θ t 2 = 0 for all t .
It is easy to obtain θ t 1 = − tαrnk − αη n − 1 n (cid:80) t − 1 s =1 e s recursively.
By the orthogonality of the subgradients, we have
[Equation]
On the other hand, the work of (Hardt et al., 2016) provided a lower bound for general non-smooth function
[Equation]
Combining Eq.
(A.7) and Eq.
(A.8)
, we have
[Equation]
A.7 Proof of Theorem 5.
We consider a general form of Theorem 5.3.
Theorem A.1 (Non-convex) .
Assume that h ( θ, z ) is L -Lipschitz, and η -approximately β -gradient
Lipschitz in θ for all given z ∈ Z .
Assume in addition that 0 ≤ g ( θ, z ) ≤ B for all θ and z .
Suppose that we run SGD on the adversarial surrogate loss with step sizes α t ≤ c/t for T steps, where c > 0 .
Then, for all t 0 ∈ { 1 , 2 , · · · , n } , adversarial training satisfies uniform stability with
[Equation]
Let q = βc .
For small T (s.t. t 0 ≤ n when we set the first term equals to the second term).
we select t 0 to optimize the right hand side, then
[Equation]
For arbitrary T , the optimal t 0 > n .
We simply let t
= 1 , then
[Equation]
Proof: Let S and S ′ be two samples of size n differing in only a single example.
Consider two trajectories θ 11 , . .
, θ T 1 and θ 12 , . .
, θ T 2 induced by running SGD on sample S and S ′ , respectively.
Let δ t =
∥
θ t 1 − θ t 2 ∥ .
Let t 0 ∈ { 0 , 1 , . .
. , n } , be the iteration that δ t 0 = 0 , but SGD picks two different samples form S and S ′ in iteration t
+ 1 , then
[Equation]
Let ∆ t =
E
[ δ t | δ t 0 = 0] .
Observe that at step t, with probability 1 − 1 /n, the example selected by
SGD is the same in both S and S ′ .
With probability 1 /n the selected example is different.
Therefore, by the αη -approximate ( 1 + αβ )-expansive property, for every t ≥ t 0 ,
[Equation]
Here we used the fact that 1 + x ≤ exp( x ) for all x.
Using the fact that ∆ t 0 = 0 , we can unwind this recurrence relation from T down to t 0 + 1 .
This gives
[Equation]
Plugging this bound into (A.13)
[Equation]
we get
[Equation]
Let q = βc .
For small T (s.t. t 0 ≤ n when we set the first term equals to the second term).
we select t 0 to optimize the right hand side
[Equation]
then
[Equation]
For arbitrary T , the optimal t 0 > n .
We simply let t
= 1 , then
[Equation]
Since the bound we just derived holds for all S, S ′ and z, we immediately get the claimed upper bound on the uniform stability.
Let q = 1 , we obtain the result of Theorem 5.3.
□
A.8 Proof of Theorem 5.
The proof follows the idea in convex case.
By the αη -approximately (1 − αγ ) -contraction, for every t,
[Equation]
Unraveling the recursion gives
[Equation]
Plugging the above inequality into Eq.
(A.4), we obtain
[Equation]
Since this bounds holds for all S, S ′ and z, the Theorem follows.
□
A.9 Proof of Theorem 6.
Let ¯ θ = 1 T (cid:80) Tt
=1 θ t denote the average of the stochastic gradient iterates.
Since θ
[Equation]
; z
[Equation]
) , we have
[Equation]
Using the αη -approximate non-expansive, we have
[Equation]
which implies
[Equation]
t = α t .
Since f is L -Lipschitz, we have
[Equation]
Here the expectation is taken over the algorithm and hence the claim follows by our definition of uniform stability.
E opt follows (Nemirovski et al., 2009).
□
B Discussion on Non-convex and Strongly Convex Case B.1 Discussion on Non-convex Case
To discuss the generalization-optimization trade-off in the non-convex case.
We first give the optimization error bound.
Theorem B.1.
Assume that h is η -approximate β -gradient Lipschitz and given 0 < τ < 1 .
Without loss of generality, assume the stochastic gradient ∇ ˜
h ( θ ) be unbiased and have a bounded variance σ 2 .
Let the stochastic gradient descent (SGD) update be θ t +
=
θ t − α ∇
˜ h
( θ t ) with a constant step size α = 1 / √ T for number of iterations T ≥ ( β/ 2(1 − τ )) 2 .
∃ t ≤ T , s.t.
[Equation]
(B.1)
Proof:
Assume that the stochastic gradient ∇ h ( θ ) be unbiased and have a bounded variance σ 2 .
[Equation]
Notice that when θ is a random vector, the above expectation is condition on θ .
Let the stochastic gradient descent (SGD) update be θ t +
=
θ t − α ˜ h
( θ t ) with a constant step size α = 1 / √ T .
By η -approximately Descent Lemma
[Equation]
we have
[Equation]
Given θ t , take the conditional expectation over the noised introduced by SGD
[Equation]
we have
[Equation]
where the first inequality is the assumption of SGD, the second inequality is the Jensen’s inequality, the third one is the assumption of SGD, the fourth one is the Cauchy-Schwartz inequality, and the last one is because of the size of step size α .
Take the expectation over the trajectory θ 0 , θ 1 , · · · , θ T , and take the average aver t = 0 , 1 , · · · , T , we have
[Equation]
Let E
[ h ( θ 0 )] − h ( θ ∗ ) =
D and divide α on both side.
∃ t ≤ T , s.t.
[Equation]
Since α = 1 / √ T , we have
[Equation]
Then we remove the absolute value, and obtain
[Equation]
By Cauchy-Schwartz inequality
[Equation]
we have
[Equation]
□
In words
[Equation]
running SGD on an approximately smooth non-convex function
[Equation]
the algorithm cannot converge to a stationary point but with an additional constant term.
Notice that this is an error bound for gradient norm.
If we need an error bound for the optimality gap, we need an additional PL condition.
Combining the optimization error and generalization error, we have
[Equation]
where the first term is an additional term for adversarial training, which induces robust overfitting.
Therefore, we can see that the analysis of the convex and non-convex cases do not have a major difference.
To simplify the argument, we only discuss the convex case in the main paper.
B.2 Discussion on Strongly Convex Case
By (Nemirovski et al., 2009),
[Equation]
in the strongly convex case.
Whether the function is smooth does not affect the convergence rate.
Therefore,
[Equation]
This result shows that robust overfitting will disappear if the loss function is strongly convex.
But the performance of adversarial training is still worse than the performance of standard training in
O ( η ) in this strong assumption.
B.3 Discussion on Strongly Concave Assumption on the Inner Problem
In this subsection, we discuss the case that g ( θ, z ) is µ -strongly concave in z .
Assumption B.1.
The function g satisfies the following Lipschitzian smoothness conditions:
[Equation]
Assumption B.1 assumes that the loss function is smooth (in zeroth-order and first-order), which are also used in the stability literature (Farnia and Ozdaglar, 2021;
Xing et al., 2021a), as well as the convergence analysis literature (Wang et al., 2019; Liu et al., 2020).
Comparing with Assumption 4.1, Assumption B.1 requires one more gradient Lipschitz ∥∇ z g ( θ 1 , z ) − ∇ θ g ( θ 2 , z ) ∥
≤ L zθ ∥
θ 1 − θ 2 ∥ .
Lemma B.1.
Under Assumption B.1, assume in addition that g ( θ, z ) is µ -strongly concave in z .
∀ θ 1 , θ 2 and ∀ z ∈ Z , the following properties hold.
[Equation]
where
[Equation]
The proof can be found in (Sinha et al., 2017; Wang et al., 2019).
Therefore, the adversarial surrogate loss is β 2 -gradient Lipschitz.
The stability generalization bounds follows (Hardt et al., 2016) by replacing β by β 2 (for the choice of step size α ).
C Additional Experiments
[Figure]
In this section
[Figure]
we provide additional experiments on SVHN, CIFAR-10, and CIFAR-100.
In Fig.
5, we show the experiments of adversarial training using a fixed learning rate.
In Fig.
6, we show the experiments of adversarial training using a standard piece-wise linear learning rate.
In Fig.
7, we show the experiments of adversarial training using cyclic learning rate.
[Figure]
Cyclic Learning Rate.
We illustrate the experiments of adversarial training using cyclic learning rate.
The learning rate increases linearly in the first 80 epochs and decreases to zero in the last 120 epochs.
This learning rate mainly contributes to optimization.
In terms of generalization, as discussed in theoretical settings, the generalization bound is no larger than that of the previous cases.
[Figure]