Convergence of Adversarial Training in Overparametrized Neural Networks
Ruiqi Gao, Tianle Cai, Haochuan Li, Liwei Wang, Cho-Jui Hsieh, Jason D. Lee
Introduction
Recent studies have demonstrated that neural network models, despite achieving human-level performance on many important tasks, are not robust to adversarial examples—a small and human imperceptible input perturbation can easily change the prediction label . This phenomenon brings out security concerns when deploying neural network models to real world systems . In the past few years, many defense algorithms have been developed to improve the network’s robustness, but most of them are still vulnerable under stronger attacks, as reported in . Among current defense methods, adversarial training has become one of the most successful methods to train robust neural networks.
To obtain a robust network, we need to consider the “robust loss” instead of a regular loss. The robust loss is defined as the maximal loss within a neighborhood around the input of each sample, and minimizing the robust loss under empirical distribution leads to a min-max optimization problem. Adversarial training is a way to minimize the robust loss. At each iteration, it (approximately) solves the inner maximization problem by an attack algorithm to get an adversarial sample, and then runs a (stochastic) gradient-descent update to minimize the loss on the adversarial samples. Although adversarial training has been widely used in practice and hugely improves the robustness of neural networks in many applications, its convergence properties are still unknown. It is unclear whether a network with small robust error exists and whether adversarial training is able to converge to a solution with minimal adversarial train loss.
In this paper, we study the convergence of adversarial training algorithms and try to answer the above questions on over-parameterized neural networks. We consider width- neural networks both for the setting of deep networks with layers, and two-layer networks for some additional analysis. Our contributions are summarized below.
For an -layer deep network with ReLU activations, and an arbitrary attack algorithm, when the width is large enough, we show that projected gradient descent converges to a network where the surrogate loss with respect to the attack is within of the optimal robust loss (Theorem 4.1). The required width is polynomial in the depth and the input dimension.
For a two-layer network with smooth activations, we provide a proof of convergence, where the projection step is not required in the algorithm (Theorem 5.1).
We then consider the expressivity of neural networks w.r.t. robust loss (or robust interpolation). We show when the width is sufficiently large, the neural network can achieve optimal robust loss ; see Theorems 5.2 and C.1 for the precise statement. By combining the expressivity result and the previous bound of the loss over the optimal robust loss, we show that adversarial training finds networks of small robust training loss (Corollary 5.1 and Corollary C.1).
We show that the VC-Dimension of the model class which can robustly interpolate any samples is lower bounded by where is the dimension. In contrast, there are neural net architectures that can interpolate samples with only parameters and VC-Dimension at most . Therefore, the capacity required for robust learning is higher.
Related Work
Adversarial examples are inputs that are slightly perturbed from a natural sample and yet incorrectly classified by the model. An adversarial example can be generated by maximizing the loss function within an -ball around a natural sample. Thus, generating adversarial examples can be viewed as solving a constrained optimization problem and can be (approximately) solved by a projected gradient descent (PGD) method . Some other techniques have also been proposed in the literature including L-BFGS , FGSM , iterative FGSM and C&W attack , where they differ from each other by the distance measurements, loss function or optimization algorithms. There are also studies on adversarial attacks with limited information about the target model. For instance, considered the black-box setting where the model is hidden but the attacker can make queries and get the corresponding outputs of the model.
Improving the robustness of neural networks against adversarial attacks, also known as defense, has been recognized as an important and unsolved problem in machine learning. Various kinds of defense methods have been proposed , but many of them are based on obfuscated gradients which does not really improve robustness under stronger attacks . As an exception, reported that the adversarial training method developed in is the only defense that works even under carefully designed attacks.
Adversarial Training
Adversarial training is one of the first defense ideas proposed in earlier papers . The main idea is to add adversarial examples into the training set to improve the robustness. However, earlier work usually only adds adversarial example once or only few times during the training phase. Recently, showed that adversarial training can be viewed as solving a min-max optimization problem where the training algorithm aims to minimize the robust loss, defined as the maximal loss within a certain -ball around each training sample. Based on this formulation, a clean adversarial training procedure based on PGD-attack has been developed and achieved state-of-the-art results even under strong attacks. This also motivates some recent research on gaining theoretical understanding of robust error . Also, adversarial training suffers from slow training time since it runs several steps of attacks within one update, and several recent works are trying to resolve this issue . From the theoretical perspective, a recent work considers to quantitatively evaluate the convergence quality of adversarial examples found in the inner maximization and therefore ensure robustness. consider generalization upper and lower bounds for robust generalization. improves the robust generalization by data augmentation with GAN. considers to reduce the optimization of min-max problem to online learning setting and use their results to analyze the convergence of GAN. In this paper, our analysis for adversarial is quite general and is not restricted to any specific kind of attack algorithm.
Global convergence of Gradient Descent
Recent works on the over-parametrization of neural networks prove that when the width greatly exceeds the sample size, gradient descent converges to a global minimizer from random initialization . The key idea in the earlier literature is to show that the Jacobian w.r.t. parameters has minimum singular value lower bounded, and thus there is a global minimum near every random initialization, with high probability. However for the robust loss, the maximization cannot be evaluated and the Jacobian is not necessarily full rank. For the surrogate loss, the heuristic attack algorithm may not even be continuous and so the same arguments cannot be utilized.
Certified Defense and Robustness Verification
In contrast to attack algorithms, neural network verification methods tries to find upper bounds of the robust loss and provide certified robustness measurements. Equipped with these verification methods for computing upper bounds of robust error, one can then apply adversarial training to get a network with certified robustness. Our analysis in Section 4 can also be extended to certified adversarial training.
Preliminaries
Let . We use to denote the standard Gaussian distribution. For a vector , we use to denote the Euclidean norm. For a matrix we use to denote the Frobenius norm and to denote the spectral norm. We use to denote the standard Euclidean inner product between two vectors, matrices, or tensors. We let , and denote standard Big-O, Big-Theta and Big-Omega notations that suppress multiplicative constants.
2 Deep Neural Networks
Here we give the definition of our deep fully-connected neural networks. For the convenience of proof, we use the same architecture as defined in .We only consider the setting when the network output is scalar. However, it is not hard to extend out results to the setting of vector outputs. Formally, we consider a neural network of the following form.
where and are the feature vectors before and after the activation function, respectively. Sometimes we also denote .
3 Perturbation and the Surrogate Loss Function
The goal of adversarial training is to make the model robust in a neighbor of each datum. We first introduce the definition of the perturbation set function to determine the perturbation at each point.
Given a perturbation set, we are now ready to define the perturbation function that maps a data point to another point inside its perturbation set. We note that the perturbation function can be quite general including the identity function and any adversarial attackIt is also not hard to extend our analysis to perturbation functions involving randomness.. Formally, we give the following definition.
With the definition of perturbation function, we can now define a large family of loss functions on the training set . We will show this definition covers the standard loss used in empirical risk minimization and the robust loss used in adversarial training.
Given a perturbation function defined in Definition 3.2, the current parameter of a neural network , and a training set , we define the surrogate loss on the training set as
It can be easily observed that the standard training loss is a special case of surrogate loss function when is the identity. The goal of adversarial training is to minimize the robust loss, i.e. the surrogate loss when is the strongest possible attack. The formal definition is as follows:
Convergence Results of Adversarial Training
We consider optimizing the surrogate loss with the perturbation function defined in Definition 3.2, which is what adversarial training does given any attack algorithm . In this section, we will prove that for a neural network with sufficient width, starting from the initialization , after certain steps of projected gradient descent within a convex set , the loss is provably upper-bounded by the best minimax robust loss in this set
Denote as the Euclidean projection to the convex set . Denote the parameter after the -th iteration as , and similarly . For each step in adversarial training, projected gradient descent takes an update
Specifically, we have the following theorem.
where .
Recall that is the loss suffered with respect to the perturbation function . This means, for example, if the adversary uses the projected gradient ascent algorithm, then the theorem guarantees that projected gradient ascent cannot successfully attack the learned network. The stronger the attack algorithm is during training, the stronger the guaranteed surrogate loss becomes.
The value of depends on the approximation capability of the network, i.e. the greater is, the less will be, thus affecting the overall bound on . We will elaborate on this in the next section, where we show that for independent of there exists a network of small adversarial training error.
Adversarial Training Finds Robust Classifier
Motivated by the optimization result in Theorem 4.1, we hope to show that there is indeed a robust classifier in . To show this, we utilize the connection between neural networks and their induced Reproducing Kernel Hilbert Space (RKHS) via viewing networks near initialization as a random feature scheme . Since we only need to show the existence of a network architecture that robustly fits the training data in and neural networks are at least as expressive as their induced kernels, we may prove this via the RKHS connection. The strategy is to first show the existence of a robust classifier in the RKHS, and then show that a sufficiently wide network can approximate the kernel via random feature analysis. The approximation results of this section will be, in general, exponential in dimension dependence due to the known issue of -dimensional functions having exponentially large RKHS norm , so only offer qualitative guidance on existence of robust classifiers.
Since deep networks contain two-layer networks as a sub-network, and we are concerned with expressivity, we focus on the local expressivity of two-layer networks. We write the standard two-layer network in the suggestive wayThis makes at initialization, which helps eliminate some unnecessary technical nuisance. (where the width is an even number)
and initialize as i.i.d. for , and is set to be equal to , is randomly drawn from and . Similarly, we define the set Note that we have taken out the term explicitly in the network expression for convenience, so in this section there is a difference of scaling by a factor of from the used in the previous section. for , being the initialization of , and fix all after initialization.
To make things cleaner, we will use a smooth activation function throughout this sectionSimilar approximation results also hold for other activation functions like ReLU., formally stated as follows.
Prior to proving the approximation results, we would like to first provide a version of convergence theorem similar to Theorem 4.1, but for this two-layer setting. It is encouraged that the reader can read Appendix B for the proof of the following Theorem 5.1 first, since it is relatively cleaner than that of the deep setting but the proof logic is analogous.
Suppose the loss function satisfies Assumption 3.1 and the activation function satisfies Assumption 5.1. With high probability, using the two-layer network defined above, for any , if we run gradient descent with step size , and if , we have
where and .
Compared to Theorem 4.1, we do not need the projection step for this two-layer theorem. We believe using a smooth activation function can also eliminate the need of the projection step in the deep setting from a technical perspective, and from a practical sense we conjecture that the projection step is not needed anyway.
Now we’re ready to proceed to the approximation results, i.e. proving that is also small, and combined with Equation (5) we can give an absolute bound on . For the reader’s convenience, we first introduce the Neural Tangent Kernel (NTK) w.r.t. our two-layer network.
For a given kernel , there is a reproducing kernel Hilbert space (RKHS) introduced by . We denote it as . We refer the readers to for an introduction of the theory of RKHS.
We formally make the following assumption on the universality of NTK.
For any , there exists , such that , for every and .
Also, we make an additional assumption on the activation function :
Under these assumptions, by applying the strategy of approximating the infinite situation by finite sum of random features, we can get the following theorem:
Given data set and a compatible perturbation set function with and its allowed perturbations taking value on , for the two-layer network defined in (4), if Assumption 3.1, 5.1, 5.2, 5.3 hold, then for any , there exists such that when the width satisfies , with probability at least 0.99 over the initialization there exists such that
Combining Theorem 5.1 and 5.2 we finally know that
Given data set on the unit sphere equipped with a compatible perturbation set function and an associated perturbation function , which also takes value on the unit sphere. Suppose Assumption 3.1, 5.1, 5.2, 5.3 are satisfied. Then for any , there exists a which only depends on dataset , perturbation and , such that for any -layer fully connected network with width , if we run gradient descent with stepsize for steps, then with probability ,
We point out that Assumption 5.2 is rather general and can be verified for a large class of activation functions by showing their induced kernel is universal as done in . Also, here we use an implicit expression of the radius , but the dependence on can be calculated under specific activation function with or without the smoothness assumptions. As an example, using quadratic ReLU as activation function, we solve the explicit dependency on in Appendix C.2 that doesn’t rely on Assumption 5.2.
Therefore, adversarial training is guaranteed to find a robust classifier under a given attack algorithm when the network width is sufficiently large.
Capacity Requirement of Robustness
In this section, we will show that in order to achieve adversarially robust interpolation (which is formally defined below), one needs more capacity than just normal interpolation. In fact, empirical evidence have already shown that to reliably withstand strong adversarial attacks, networks require a significantly larger capacity than for correctly classifying benign examples only . This implies, in some sense, that using a neural network with larger width is necessary.
We begin with the definition of the interpolation class and the robust interpolation class.
We say that a function class is an -robust interpolation class, if the following is satisfied:
We will use the VC-Dimension of a function class to measure its complexity. In fact, as shown in (Equation(2)), for neural networks there is a tight connection between the number of parameters , the number of layers and their VC-Dimension
In addition, combining with the results in (Theorem 3) which shows the existence of a 4-layer neural network with parameters that can interpolate any data points, i.e. an -interpolation class, we have that an -interpolation class can be realized by a fixed depth neural network with VC-Dimension upper bound
For a general hypothesis class , we can evidently see that when is an -interpolation class, has VC-Dimension at least . For a neural network that is an -interpolation class, without further architectural constraints, this lower bound of its VC-dimension is tight up to logarithmic factors as indicated in Equation (7). However, we show that for a robust-interpolation class we will have a much larger VC-Dimension lower bound:
If is an -robust interpolation class, then we have the following lower bound on the VC-Dimension of
where is the dimension of the input space.
For neural networks, Equation (8) shows that any architecture that is an -robust interpolation class should have VC-Dimension at least . Compared with Equation (7) which shows an -interpolation class can be realized by a network architecture with VC-Dimension , we can conclude that robust interpolation by neural networks needs more capacity, so increasing the width of neural network is indeed in some sense necessary.
Discussion on Limitations and Future Directions
This work provides a theoretical analysis of the empirically successful adversarial training algorithm in the training of robust neural networks. Our main results indicate that adversarial training will find a network of low robust surrogate loss, even when the maximization is computed via a heuristic algorithm such as projected gradient ascent. However, there are still some limitations with our current theory, and we also feel our results can lead to several thought-provoking future work, which is discussed as follows.
Removal of projection. It is also natural to ask whether the projection step can be removed, as it is empirically unnecessary and also unnecessary for our two-layer analysis. We believe using smooth activations might resolve this issue from a technical perspective, although practically it seems the projection step in the algorithm is unnecessary in any case.
Generalizing to different attacks. Firstly, our current guarantee of the surrogate loss is based on the same perturbation function as that used during training. It is natural to ask that whether we can ensure the surrogate loss is low with respect to a larger family of perturbation functions than that used during training.
Exploiting structures of network and data. Same as the recent proof of convergence on overparameterized networks in the non-robust setting, our analysis fails to further incorporate useful network structures apart from being sufficiently wide, and as a result increasing depth can only hurt the bound. It would be interesting to provide finer analysis based on additional assumptions on the alignment of the network structure and data distribution.
Improving the approximation bound. On the expressivity side, the current argument utilizes that a neural net restricted to a local region can approximate its induced RKHS. Although the RKHS is universal, they do not avoid the curse of dimensionality (see Appendix C.2). However, we believe in reality, the required radius of region to achieve robust approximation is not as large as the theorem demands. So an interesting question is whether the robust expressivity of neural networks can adapt to structures such as low latent dimension of the data mechanism , thereby reducing the approximation bound.
Capacity requirement of robustness and robust generalization. Apart from this paper, there are other works supporting the need for capacity including the perspective of network width , depth and computational complexity . It is argued in that robust generalization is also harder using Rademacher complexity. In fact, it appears empirically that robust generalization is even harder than robust training. It is observed that increasing the capacity, though benifiting the dacay of training loss, has much less effect on robust generalization. There are also other factors behind robust generalization, like the number of training data . The questions about robust generalization, as well as to what extent capacity influnces it, are still subject to much debate.
The above are several interesting directions of further improvement to our current result. In fact, many of these questions are largely unanswered even for neural nets in the non-robust setting, so we leave them to future work.
Acknowlegements
We acknowlegde useful discussions with Siyu Chen, Di He, Runtian Zhai, and Xiyu Zhai. RG and TC are partially supported by the elite undergraduate training program of School of Mathematical Sciences in Peking University. LW acknowledges support by Natioanl Key R&D Program of China (no. 2018YFB1402600), BJNSF (L172037). JDL acknowledges support of the ARO under MURI Award W911NF-11-1-0303, the Sloan Research Fellowship, and NSF CCF #1900145.
References
Appendix A Proof of the Convergence Result for Deep Nets in Section 4
and the gradient w.r.t. is
First, we will restate some basic results at initialization.
If , with probability at initialization, we have , , and .
For any fixed input , with probability over the randomness of initialization, we have for every , and at initialization.
This is a restatement of Lemma 7.1 in taking the number of data . ∎
If , for any fixed input , with probability , at initialization we have for every ,
Note that and . This lemma then becomes a direct consequence of Lemma A.1 and Lemma 7.3(a) in with number of data . ∎
Our general idea is that within the local region (where )
the gradient remains stable over when is fixed, and the perturbation of is small compared to the scale of . This property has been studied in extensively. However, in the non-adversarial setting, they only need to prove this property at finitely many data points . In our adversarial training setting, though, we also need to prove that it holds for any . Specifically, in this section we would like to prove that it holds for any . Our method is based on viewing the perturbation of as an equivalent perturbation of the parameter , and then we will be able to make use of the results in . This is elaborated in the following lemma:
Given any fixed input . If , with probability over random initialization, for any satisfying , and any , there exists such that for , and for all we have
In other words, the network with a perturbation from to is same as the network with a perturbation from to since layer and up.
By Lemma A.1, with probability , and . Thus . By Lemma A.2, with probability , . Let
obviously satisfies . Then setting equal to will make all the following hidden layer vectors and equal. It is also easy to verify that
so we know that . ∎
By Lemma A.4, we can directly apply many results in which are only intended for the fixed data originally, to our scenario where the input can be perturbed, as long as we take the parameter radius as in their propositionsNote that in the corresponding region is defined by the -norm instead of the -norm: . Since obviously , we can still apply their results to our case directly.. This can give us the following important lemma:
Given any fixed input . If , for some sufficiently small constant , then with probability at least over random initialization, we have for any and any with ,
By Lemma 8.2(b)(c) of , using the method of Lemma A.4 stated above, when , with probability , for any and any with , we have for , Here the zero norm denotes the number of non-zero entries of a matrix or a vector.
where (11) is also easily verified to hold for . Next, according to Lemma 8.7 of We only use the setting when the network output is a scalar., when the bound (10) satisfies , with probability , we have for any and any with , ,
Note that with our condition , the previous requirements are all satisfied. Also, combining (11) with Lemma A.2, we know for ,
Combining Equation (11), (12), (13), and Lemma A.3, we obtain
With Lemma A.5, we are ready to state an important bound that implies the loss function is close to being convex within the neighborhood for any . We use the -net to turn the result from a fixed to all ,
where the first inequality uses the convexity of w.r.t and the last inequality is due to the boundedness of is bounded, Lemma A.5, and . We take . With the requirement can be satisfied. Therefore, taking union event over all points, our proposition holds with probability
where the last equation is due to the condition . ∎
With the above preparations, we are ready to prove the main theorem.
We denote as the parameter after steps of projected gradient descent, starting from the initialization . We perform a total of steps with step size .
For projected gradient descent, holds for all . Recall that the update rule is for . Let . We have
where the second inequality is due to Lemma A.6 and Lemma A.5, the third inequality is due to the definition of . Note that in order to satisfy the condition for Lemma A.6 and Lemma A.5, our choice suffices. By induction on the above inequality, we have
where in the last inequality we use our choice of , , and also , which is satisfied by .
Appendix B Proof of Theorem 5.1: Convergence Result for Two-Layer Networks
We denote as the parameter after steps of projected gradient descent, starting from the initialization . We perform a total of steps with step size , where each step is an update . Firstly, the formula for the network gradient is
where is the parameter for the output layer. We can compute the Lipschitz property of w.r.t : For any fixed ,
In addition, we can also easily know that for and , , we have
since the initialization satisfies with high probability given (see Lemma A.1), thereby .
Denote . Without a projection step, there could be two possible scenarios during the optimization process: Either holds for all , or there exists some such that for but . Either way, while is still in up to , we have
where the first inequality is based on (14) and (15), the second inequality is based on the definition of , and is some constant. Let which is a geometric series, and dividing (16) by we have
and note that , which yields
Now we will consider the two cases separately:
Case 1. holds for all . We have chosen , and then . Also, since , by choosing and , and taking in (17), we can obtain .
Case 2. There exists some such that for but . Since , we know that and . Still using the choice of parameters above, we have . Hence, taking in (17), we obtain .
So in any case the result is correct, thus we have proved the convergence without the need of projection. ∎
Appendix C Proof of Gradient Descent Finding Robust Classifier in Section 5
As discussed in Section 5, we will use the idea of random feature to approximate on the unit sphere. We consider functions of the form
Let and be defined as above. Then is dense in , and further, dense in w.r.t. , where .
We then show that we can approximate elements of by finite random features. Our results are inspired by . For the next theorem, recall Assumption 5.1, 5.3, the constant satisfies is -Lipschitz, .
This result is obtained by importance sampling, where we construct with . We first notice that which satisfies the condition of the theorem. We then define the random variable
We bound this deviation from its expectation using McDiarmid’s inequality.
by using triangle, Cauchy-Schwartz inequality, and .
where is a sequence of Rademacher random variables.
Since and is -Lipschitz, we have that is -Lipschitz in the scalar argument and zero when the scalar argument is zero. Following (18), by Talagrand’s lemma (Lemma 5.7) in together with Cauchy-Schwartz, Jensen’s inequality, we have
The proposition is proved by solving the while setting the right hand to the given . ∎
. Finally, we construct within a ball of the initialization that suffers little robust loss . Using the symmetric initialization in (4), we have for all . We then use the neural Taylor expansion w.r.t. the parameters:
where denotes the value of at initialization. We omitted the second order term. The term (i) has the form of the random feature approximation, and so Proposition C.1 can be used to construct a robust interpolant.
In summary, we give the entire proof of Theorem 5.2 as follows.
By Assumption 5.2 with , there exists such that
for every , , where is the perturbation set.
such that satisfies
with probability at least on the initialization ’s.
We decompose into the linear part and its residual:
Then set , we have
Finally, set to be large enough () so that the left hand in Equation (19) no more than and let to be . Then
The theorem follows by setting . ∎
C.2 Example of Using Quadratic ReLU Activation
The dataset and the perturbation set function satisfies the following: There does not exist and such that but .
And then we can derive the finite-sum approximation result by random features.
For a given Lipschitz function . For , let be sampled i.i.d. from the uniform distribution on the surface of the sphere of radius where
Let . For , let be the uniform distribution on . Let be sampled i.i.d. from uniform distribution on the surface of the sphere of radius , then for any , if
Then we can give the proof of Theorem C.1.
Let denote the Lipschitz coefficient of . We consider in Lemma C.2, by the property of Lipschitz coefficient, we have
By Lemma C.2, for some constant , when , Equation (25) fails, so holds and at the same time we have for some that only depends on the data and the perturbation. ∎
Now, we get a similar but more explicit finite-sum approximation result for quadratic ReLU activation, we are then going to show that the RKHS is rich enough that Assumption 5.2 can be derived. We have the following lemma to characterize the capacity of the RKHS.
Then, by plugging-in the finite-sum approximation theorem (Theorem C.1) and the theorem of the capacity of RKHS (Theorem C.3) to the proof of Theorem 5.2 and combining with the optimization theorem, we can get an overall theorem for the quadratic-ReLU network which is similar to Corollary 5.1 but with explicit dependence:
Given data set on the unit sphere equipped with a compatible perturbation set function and an associated perturbation function , which also takes value on the unit sphere. Suppose Assumption 3.1, C.1 are satisfied. Let be a constant that only depends on the dataset and perturbation . Then for any -layer quadratic-ReLU network with width , if we run gradient descent with stepsize for steps, then with probability ,
Appendix D Proof of Theorem 6.1
We prove this theorem by an explicit construction of data points that is guaranteed to be able to shatter. Consider the following data points
we can always put . This also holds in the case that or is empty, where we can simply put one ball centered at and put anywhere far away so that it is disjoint from the other balls. Recall that we have chosen for . Such balls are disjoint since , and for . In this way, since is an -robust interpolation class, we can use the fact that there exists a function such that for any , for and for . In this way, holds for all . Since the labels can be picked at will, by the definition of the VC-dimension, we know that the VC-dimension of is always at least . ∎