Feature Purification: How Adversarial Training Performs Robust Deep Learning
Zeyuan Allen-Zhu, Yuanzhi Li
Introduction
Large scale neural networks have shown great power to learn from a training data set, and generalize to unseen data sampled from similar distributions for applications across different domains . However, recent study has discovered that these trained large models are extremely vulnerable to small “adversarial attacks” . It has been discovered that small perturbations to the input– often small enough to be invisible to humans– can create numerous errors in prediction. Such slightly perturbed inputs are often referred to as “adversarial examples”.
Since the original discovery of “adversarial examples”, a large body of works have been done emphasizing how to improve the robustness of the deep learning models against such perturbations . One seminal approach is called adversarial training , where one iteratively computes adversarial examples from the training examples, and then retrain the model with these adversarial examples instead of the original examples (a.k.a. the clean examples). This approach was reported in as the only approach that can defend against carefully designed adversarial attacks, and many follow-up works are built upon it .
However, despite the great empirical success on improving the robustness of neural networks over various data sets, the theory of the adversarial examples is much less developed. In particular, we found that the following fundamental questions remain largely unaddressed:
To answer these questions, one sequence of theoretical works try to explain the existence of adversarial examples using the high dimensional nature of the input space and the over-fitting behavior due to the sample size and sample noise , and treat adversarial training from the broader view of min-max optimization . However, recent observations indicate that these adversarial examples can also, and arguably often, arise from features (those that do generalize) rather bugs (those that do not generalize due to effect of poor statistical concentration). To the best of our knowledge, all existing works studying adversarial examples either (1) apply generally to the case of arbitrarily unstructured functions and only consider adversarial examples statistically, or (2) apply to a structured setting but only involving linear learners. These theoretical works, while shedding great lights to the study of adversarial examples, do not yet give concrete mathematical answers to the following questions regarding the specific hidden-layer structure of neural networks:
What are the features (i.e. the hidden weights) learned by the neural network via clean training (i.e., over the original data set)? Why are those features “non-robust”?
What are the differences between the features learned by clean training vs adversarial training (i.e., over a perturbed data set consisting of adversarial examples)?
Why do adversarial examples for a network transfer to other independently-trained networks?
Before going into the above questions regarding robustness, it is inevitable to first study what the features are when learned by a neural network during clean training. Theoretical studies are also limited in this direction. Most of existing works (1) only focus on the case when the training data is spherical Gaussian , and some of them require heavy initialization using tensor decomposition, which might fail to capture the specific structure of the input and the property of a random initialization; or (2) only consider the neural tangent kernel regime, where the neural networks are linearized so the features are not learned (they stay at random initialization) .
In this paper, we present a new routine that enables us to formally study the learned features (i.e. the hidden weights) of a neural network, when the inputs are more naturally structured than being Gaussians. Using this routine, we give, to the best of our knowledge, the first theoretical result towards answering the aforementioned fundamental questions of adversarial examples, for certain neural networks with ReLU activation functions.
Our results. We prove, for certain binary classification data set, when we train a two-layer ReLU neural network using gradient descent,Our theory extends to stochastic gradient descent (SGD) at the expense of complicating notations. starting from random initialization,
Given polynomially manly training examples, in polynomially many iterations, the neural network will learn well-generalizing features for the original data set, and the learned network will have close-to-perfect prediction accuracy for the test data sampled from the same distribution.
However, even with a weight-decay regularizer to avoid over-fitting, even with infinitely many training data, and even when super-polynomially many iterations are used to train the neural network to convergence, the learned network still has near-zero robust accuracy against small-norm adversarial perturbations to the data. In other words, those provably well-generalizing features on the original data set are also provably non-robust to adversarial perturbations to the datas, so they cannot be due to having too few training samples .
Adversarial training, using perturbation algorithms such as Fast Gradient Method (FGM) , can provably and efficiently make the learned neural network achieve near-perfect robust accuracy, against even the worst-case norm-bounded adversarial perturbations, using a principle we refer to as “feature purification”. We illustrate “feature purification” in Figure 1 by an experiment, and explain it in mathematical terms next.
Feature purification: How adversarial training can perform robust deep learning. In this work, we also give precise, mathematical characterizations on the difference between learned features by clean training versus adversarial training in the aforementioned setting, leading to (to our best knowledge) the first theory of how, in certain learning tasks using ReLU neural networks, the provably non-robust features after clean training can be “robustified” via adversarial training.
We emphasize that prior theoretical works mainly study adversarial examples in the context of linear models (such as linear regression, linear regression over prescribed feature mappings, or the neural tangent kernels). In those models, the features are not trained, so adversarial training only changes the weights associated with the linear combination of these features, but not the actual features themselves.
In contrast, this paper develops a theory showing that how, over certain learning tasks, adversarial training can actually change the features of certain neural networks to improve their robustness. We abstract this feature change in our setting into a general principle that we call feature purification, which although we only prove it for two-layer ReLU networks (see Theorem thm:intro:cleansa+Theorem thm:adv1_sc), we empirically observe that it occurs more generally to real-world, deep neural networks on real-world data sets. We sketch its high-level idea as follows.
Mathematically, as a provisional step to measure of change of features in a network, let us use (1) to denote the weight vector of the -th neuron at initialization, (2) to denote its weight after clean training, and (3) to denote its weight after adversarial training (using as initialization). The “feature purification” principle, in math, says if we use as a provisional measure of the correlation between “features”, then (see Figure 2 for real-life experiments):
for most neurons: for a small constant (such as );
for most neurons: for a large constant (such as ); and
for most pairs of different neurons: for a small constant (such as ).
In words, this says both clean training and adversarial training discover hidden weights that are fundamentally different from initialization . However, since and are close, clean training must have already discovered a big portion of the robust features, and adversarial training merely needs to “purify” some small part of each original feature. In this paper:
we prove this feature purification principle in the case of two-layer ReLU neural networks over certain data sets, with and (see Theorem thm:intro:cleansa+Theorem thm:adv1_sc); and
we provide empirical evidence that this feature purification principle holds also for deep neural networks used in real-life datasets (see Figure 2 as well as other experiments in the paper).
Why clean training learns non-robust features? Which part of the features are “purified” during adversarial training? In our setting, we also give mathematical characterizations of where the “non-robust” part of each feature comes from during clean training.
As we shall formally discuss in Section 6.2, training algorithms such as gradient descent will, at every step, add to the current parameters a direction that maximally correlates with the labeling function on average. For two-layer ReLU networks, we prove that such simple correlations will accumulate, in each neuron, a small part of its weight that correlates with the average of the training data, and we refer to it as the dense mixture (see Theorem 5.2). However, under natural assumptions of the data such as the sparse coding model — namely inputs come from sparse combinations of hidden dictionary words/vectors— such dense mixtures cannot have high correlation with any individual, clean example. Thus, even with these “dense mixtures” in the features, the network can still generalize well on the original data set. However, we show that these portions of the features are extremely vulnerable to small, adversarial perturbations along the “dense mixture” directions. As a result, one of the main goals of adversarial training, as we show, is to purify the neurons by removing such dense mixtures. This is the supporting theory behind our feature purification principle, as we also measure and verify it empirically in the experiment section.
We believe our result extends the reach of traditional learning theory, where often statistical properties of the model (such as generalization, etc.) is separate from optimization (i.e., how the models are trained). However, to understand adversarial examples in deep learning, one needs to admit that well-generalizing and adversarially robust neural networks do exist (and can even be found efficiently using adversarial training), thus it is also a global optimal solution of the clean training objective. It is rather a property of traditional clean training process using SGD which biases the network towards learning non-robust networks as another global optimal solution of the training objective.
Moreover, in our setting, these dense mixtures in the hidden weights of the network come from the sparse coding structure of the data and the gradient descent algorithm. It is rather independent of the random initialization of the neural network. Thus, we prove that, at least in our scenario, adversarial examples for one network do transfer to other independently trained ones.
Our contribution to computation complexity. We also prove a lower bound that, for the same sparse coding data model, even when the original data is linearly-separable, any linear classifier, any low-degree polynomial, or even the corresponding neural tangent kernel (NTK) of our studied two-layer neural network, cannot achieve meaningful robust accuracy (although they can easily achieve high clean accuracy). Together with our upper bound, we have shown that using a higher-complexity model (such as a two-layer neural network with ReLU activation, comparing to NTK) can in fact achieve better robustness against adversarial perturbations. Thus, our theory strongly supports the experimental finding in , where experts have noticed that robustness against adversarial examples requires a model with higher complexity. The main intuition is that low-complexity models, including the neural tangent kernel, lacks the power to zero out low magnitude signals to improve model robustness, as illustrated in Figure 3 and Section 3.
Our experimental contributions. We present quite a few experimental results supporting our theory. We find that our sparse coding model can indeed capture real-world data to certain degree, and our principle of feature purification also holds for architectures such as AlexNet and ResNet. We showed during clean training, how the features can emerge from random initialization by wining the “lottery tickets”, as predicted by our theory. Perhaps most importantly, we confirmed through experiments that:
Adversarial training using adversarial examples indeed purify “dense mixtures” in practice.
To gain robust accuracy, it suffices to remove such “dense mixtures” (via a low-rank update).
We present our experiments following each of the theorem statements accordingly. We also include a whole Section 8 for more detailed experiments.
Adversarial examples: Empirical study. Since the seminal paper shows the existence of small adversarial perturbations to change the prediction of the neural networks, many empirical studies have been done to make the trained neural networks robust against perturbations (and we refer to the citations therein). The recent study shows that the seminal approach of adversarial training is the most effective way to make the neural networks robust against adversarial perturbations.
Adversarial examples: Theoretical study. Existing theories mostly explain the existence of adversarial examples as the result of finite-sample data set over-fitting to high-dimensional learning problems . Later, it is discovered by Ilyas et al. that well-generalizing features can also be non-robust. Other theories focus on the Fourier perspective of the robustness , showing that adversarial training might be preventing the network from learning the high frequency signals of the input image. Our theoretical work is fundamentally different from the aspect of poor statistical concentration over finite-sample data set, and our Theorem 5.1 and Theorem 5.3 strongly supports that a well-trained, well-generalizing neural network can still be non-robust to adversarial attacks.
Other theories about adversarial examples focus on how adversarial training might require more training data comparing to clean training , and might decrease clean training accuracy . The works by focus on how adversarial training can be performed efficiently in the neural tangent kernel regime. The purpose of these results are also fundamentally different than ours.
Sparse coding (data) model. We use a data model called sparse coding, which is a popular model to model image, text and speech data . There are many existing theoretical works studying algorithm for sparse coding , however, these algorithms share little similarity to training a neural network.
The seminal work by Arora et al. provides a neurally-plausible algorithm for learning sparse coding along with other works using alternative minimization . However, all of these results require a (carefully picking) warm start, while our theory is for training a neural network starting from random initialization.
Threshold degree and kernel lower bound. We also provide, to the best of our knowledge, the first example when the original classification problem is learnable using a linear classifier but no low-degree polynomial can learn the problem robustly against small adversarial perturbations. Yet, the high-complexity neural networks can provably, efficiently and robustly learn the concept class. The lower bound for the classification accuracy using low-degree polynomials has been widely studied as the (approximate) threshold degree of a function or the sign-rank of a matrix . Our paper give the first example of a function with high (approximate) robust threshold degree, yet efficiently and robustly learnable by training a ReLU neural network using gradient descent.
Other related works prove lower bounds for kernel method in the regression case . Generally speaking, such lower bounds are about the actual (approximate) degree of the function, instead of the (approximate) threshold degree. It is well know that for general functions, the the actual degree can be arbitrary larger than the threshold degree.
Preliminaries
We assume the hidden vector is “sparse”, in the following sense: for , we have:
The coordinates of are independent, symmetric random variables, such that . Moreover,
Under Assumption 2.1, w.h.p., is a sparse vector.
We study the simplest binary-classification problem, where the labeling function is linear over the hidden vector :
For simplicity, we assume , so all the coordinates of have relatively equal contributions. Our theorems extend to other at the expense of complicating notations.
Remark on sparse coding. The sparse coding model is very natural and is widely used to model image, text and speech data . There certainly exist (provable) algorithms for dictionary learning based on sum of squares, linear programming , but they do not shed light on the training process of neural networks. Even the neural algorithm for sparse coding is still far away from training a neural network using SGD or its variants. The main point of this paper is not to show neural networks can do sparse coding. Instead, our main point is to distinguish the adversarial training and the clean training processes of neural networks using the sparse-coding model as a bridging tool.
Noise model. We have allowed the inputs to incorporate a noise vector . Our lower bounds hold even when there is no noise (). Our upper bound theorems not only apply to , but more generally to “gaussian noise plus spike noise”:
the noise can be of Euclidean norm , larger than the signal ; and
the spike noise can be which is the maximum possible (because can be ).
Clean and robust error. The goal of clean training is to learn a model so that is as close to as possible. We define the classification error on the original data set as:
Warmup Intuitions
Linear learners are not robust. Given the setting of the data set, one direct approach is to use (the sign of) a linear classifier to predict the label of . There are two issues of using such a classifier:
When is as large as , such classifier can not even classify in good clean accuracy. Recall . By our assumption, typically and . Thus, when , noise could be much larger than signal, and this linear classifier cannot be used to classify correctly. In this case, actually no linear classifier (or even constant-degree polynomials One may think that using for example degree-3 polynomial can reduce the level of noise, but due to the diversity in the value of when , one must use something close to linear when is large. Applying Markov brothers’ inequality, one can show the low-degree polynomial must be close to a linear function.) can give meaningful clean accuracy.
High-complexity models are more robust. Another choice to learn the labeling function is to use a higher-complexity model . Here, the “complexity” of is much higher because an indicator function is used.One concrete measure of “higher complexity” is that cannot be well-approximated by low degree polynomial. Since , by our noise model, as long as the signal is non-zero, with high probability. Thus, this is equal to the true labeling function w.h.p. over the original data set, so is (much) more robust to noise comparing to linear models.
To sum up, higher-complexity models (such as those using ReLU) have the power to zero out low-magnitude signals to improve adversarial robustness, as illustrated in Figure 3.
Learning robust classifier using neural network. Motivated by the above discussions between linear vs. high-complexity models, our goal is to show that a two-layer neural networks can (after adversarial training) learn a robust function such as
Here, is the ReLU function and . In this paper, we present a theorem stating that adversarial training of a (wlog. symmetric) two-layer neural network can indeed recover a neural network of this form. In other words, after adversarial training, the features learned by the hidden layer of a neural network can indeed form a basis (namely, ) of the input where the coefficients are sparse. We also present a theorem showing why, clean training will not learn this robust function. We also verify experimentally that the features learned by the first layer of AlexNet (after adversarial training) indeed form a sparse basis of the images, see Figure 4.
Learner Network and Adversarial Training
In this paper we consider a simple, two layer (symmetric) We assume the neurons are symmetric (i.e., with pairs) to simplify proofs. neural network with ReLU activation.
To simplify analysis, we fix throughout the training. We use to denote the hidden weights at time , and use to denote the network at iteration
Given a training set together with one sample of pre-activation noise for each , we define
In our case, the (clean, population) classification error at iteration is
At initialization, we let for and let . When near initialization, we manually increase the bias where for some small constant — this corresponds to the “lottery ticket winning” phase to be discussed later in Section 6.1; and whenever reaches we set — in this phase, the neurons that have won the “lottery ticket” will keep winning and grow significantly, to be discussed in Section 6.2.
We also choose pre-activation noise for , and for . The explicit choices of and are given in the proofs.
2 Adversarial Training
We state the adversarial training algorithm in Algorithm 2. It takes as input a perturbation algorithm , and repeatedly applies gradient descent over a perturbed data set (that comes from the original data set plus the perturbation given by ). Formally,
In contrast, the empirical robust classification error against algorithm is
Our upper bound theorems apply to all perturbation algorithms under Definition 4.2, and gives small empirical robust error . To obtain small (true) robust error , as we shall see, one can for instance let be the fast gradient method (FGM).
Initialized from clean training. In this paper, we assume adversarial training (i.e., Algorithm 2) is initialized from a network that is already clean-trained. In contrast, in practice, adversarial training usually begins directly with random initialization. We remark here that:
First, in practice, adversarial training from a clean-trained initialization performs no worse than from a random initialization, see Table 1 on Page 1. In fact, it is sometimes even beneficial to begin with clean training and gradually switch to adversarial training (see e.g. ).
Second, to prove our main conceptual message— feature purification— it is convenient to start from a clean-trained model, and then try to understand which part of the features are changed after robust training. Since neural nets have lots of equivalent transformations that are not very well-understood (even in two-layer case), if we adversarially train it from random initialization, then it is theoretically very hard to quantify how it is related to another clean-trained model learned from random initialization (since we need to understand all the invariants).Even if one performs clean/adversarial training from the same random initialization, the additional randomness in SGD may quickly make the two models diverge from each other.
Yet, our theory still gives support to what happens in adversarial training from random initialization. As we shall prove, this “ feature change” comes from dense mixtures directions (see Theorem 5.2). Thus, adversarial training from random initialization should directly avoid learning such dense mixtures, as opposed to first learning them (by clean training) and then forgetting (by adversarial training). We illustrate this in Figure 9.
Statements and Explanations of Our Main Results
There exists an absolute constants such that for every constant , every and with , given many training data, for every random initialization weight , for every learning rate \eta\in\big{(}0,\frac{1}{\Omega(d^{C})}\big{]}, if we define , then for every , the following holds with high probability. The network with hidden weights learned by clean training Algorithm 1 satisfies:
Global feature learning: for every ,
Clean training has good clean accuracy: for every ,
Clean training is not robust to small adversarial perturbations: for every , every , using perturbation (which does not depend on ),
Theorem 5.1 indicates that in our setting, clean training of the neural network has good clean accuracy but terrible robust accuracy. Such terrible robust accuracy is not due to over-fitting, as it holds even when a super-polynomially many iterations and infinitely many training examples are used to train the neural network. In the next theorem, we give a precise characterization of what the hidden weights are after clean training, and why they are not robust.
For every neuron , there is a fixed subset of size such that, for every ,
where (1) for some small constant , and (2) for at least many neurons , it satisfies and . Moreover,
Theorem 5.2 says that each neuron will learn constantly many (allegedly large) components in the directions \big{\{}\mathbf{M}_{j}\colon j\in\mathcal{N}_{j}\big{\}}, and its components in the remaining directions \big{\{}\mathbf{M}_{j}\colon j\not\in\mathcal{N}_{j}\big{\}} are all small. We emphasize that the sets are independent of but are solely determined by random initialization. In other words, for each neuron , which setset it “wins” is completely determined by the “lottery ticket” (its random initialization). We discuss this in more details in Section 6.1.
Furthermore, Theorem 5.2 shows that instead of learning the pure, robust features , intuitively, ignoring the small factors, focusing only on those neurons with , and assuming for simplicity all the ’s are of similar (positive) magnitude, then, clean training will learn neurons:
Feature purification: mathematical reasoning. Eq. (5.1) says that, after clean training, the neural network will be able to learn a big portion of the robust feature, , plus some small dense mixture v=\sum_{j^{\prime}\not=j}\big{[}\Theta\left(\frac{k}{d}\right)w_{j^{\prime}}^{\star}\mathbf{M}_{j^{\prime}}\big{]}. In our sparse coding model, each is of form , where is a sparse vector and is the noise. One critical observation is that such dense mixture has low correlation with almost all inputs from the original distribution, so it has negligible effect for clean accuracy. However, such dense mixture is extremely vulnerable to small but dense adversarial perturbations of the input along this direction , making the model non-robust.
As we point out, such “dense adversarial perturbation” directions do not exist in the original data.One can try to add these dense mixtures directly to the training data set, which we conjecture to be similar to the approach in Thus, one has to rely on adversarial training to remove dense mixtures to make the model robust. This is the main spirit of our feature purification principle, and we illustrate it in Figure 6.
Where does dense mixture come from? We shall explain in more details in Section 6.2, but at a high level, in each iteration, the gradient will bias towards the direction that correlates with the labeling function ; and since in our model, such direction should be , so is a dense mixture direction and will be accumulated across time. The accumulation of dense mixture is consistent with the finding (for linearly-separable data).
However, as we have argued in Section 3, in our setting when the noise level is large, such dense mixture direction cannot be used to given even good clean accuracy. Therefore, during clean training, the neural network has the incentive to discover features close to because they can “de-noise” better (see discussions in Section 3). Yet, our critical observation is that, even for well-trained neural network which aims to de-noise , even when the neurons are close to being pure features , the “dense direction” still locally correlates with the labeling function , and thus can still be accumulated during the course of a local training algorithm such as gradient descent, leading to the small, non-robust part of each feature.
Next, we state the theorem for adversarial training (recall Algorithm 2). It shows that adversarial training indeed purifies the small dense mixtures, leading to local changes of the weights.
Empirical robust accuracy: for
Provable robust accuracy: when is the fast gradient method (FGM), for
Feature (local) purification: for every ,
We emphasize that Theorem thm:adv1_sa holds for any perturbation algorithm satisfying Definition 4.2, when we only concern the robustness of the network against . Meaning that the local feature purification happens regardless of which adversarial perturbation algorithm is used to find the adversarial examples. More surprisingly, Theorem thm:adv1_sb says when a good perturbation algorithm such as FGM is used, then not only the robustness generalizes to unseen examples, it also generalizes to any worst-case perturbation algorithm.We point out that since our results hold for any perturbation algorithm , it is impossible to characterize exactly what are the learned features after training (for example showing that they corresponds to the actual dictionary) since might be a bad adversarial perturbation finding algorithm and the network does not even need to remove all the dense mixture in order to fool . However, the true robustness given by Theorem thm:adv1_sb does imply that the dense mixture should be removed at least in terms of functionality, if one uses a good adversarial perturbation finding algorithm.
Given that this “dense mixture” direction is common across neurons, one may think that during adversarial training, instead of training all the parameters, it may be sufficient to train a low-rank update on top of the clean-trained model. In practice, this indeed works very well, see Section 8.5.
Density of adversarial perturbation. Our previous theorem suggests that one of the main goals of adversarial training is to remove dense mixtures to make the network more robust. Therefore, before adversarial training, the adversarial perturbations are dense in the basis of ; and after adversarial training, the adversarial perturbations ought to be more sparse and aligned with inputs from the original data set. Figure 7 has confirmed this theoretical finding using real-life data sets. Later in Section 8.3, we also present concrete measurements of the sparsity of these adversarial perturbations, and compare them in Figure 12.
This gives a gap because can be made arbitrarily small. (see Theorem E.1 and Theorem F.4)
We also show a lower bound that no low-degree polynomial, or even the corresponding neural tangent kernel (NTK), can robustly learn the concept class. Recall for our two-layer ReLU network,
The feature mapping of the neural tangent kernel for our two-layer network is
Therefore, given weights , the NTK function is given as
Without loss of generality, assume each .
In this paper, we consider a wide range of NTK parameters: for arbitrary and .
Our lower bound holds even for a most simple case and , so the original concept class is linearly separable. We prove the following:
(In contrast, Theorem 5.5 says adversarial training of neural network gives robust radius .)
Since a poly-sized NTK kernel is known to be powerful enough to incorporate any low complexity functions (such as constant-degree polynomials) , we have the following corollary.
In the same setting as Theorem 5.7, if is a constant degree polynomial, then we also have the robust error .
Overview of the Training Process
In this section, we present an overview of the proof for the training process, using gradient descent starting from random initialization. The complete proof is deferred to the Appendix.
Our proof begins by showing how the features in the neural network are emerged from random initialization. In this phase, the loss function is not sufficiently minimized yet, so the classification accuracy remains around . However, we prove in this phase, gradient descent can already drive the neural network to learn a rich set of interesting features out of the random initialization. We call this process “lottery ticket winning” near random initialization, which is related to the study of .
This “lottery ticket winning” process is fundamentally different from the neural tangent kernel analysis (e.g. ). In this phase, although the loss is not sufficiently minimized, the activation patterns of the ReLU activations have changed dramatically, so that they have little correlations with the random initialization. Yet, we develop a new theoretical technique that allows us to control the change of the weights of the neurons, as we summarize below.
We derive the following property at random initialization. At iteration , the hidden weights are initialized as w_{i}^{(0)}\sim\mathcal{N}\big{(}0,\sigma_{0}^{2}\mathbf{I}_{d\times d}\big{)}. Using standard properties of Gaussians, we show the following critical property: as long as , there exists small constants such that
For most of the neurons , .
For at most fraction of of the neurons , there is a dimension with .
For at least fraction of of the neurons , there is one and only one such that , and all the other satisfies .
In other words, even with very mild over-parameterization , by the property of random gaussian initialization, there will be some “potentially lucky neurons” in (ii), where the maximum correlation to one of the features is slightly higher than usual. Moreover, there will be some “surely lucky neurons” in (iii), where such “slightly higher correlation” appears in one and only one of the target features .
In our proof, we denote the set of the neurons in (iii) whose correlation with is slightly higher than usual as the set , and denote those in (ii) as . We will identify the following process during the training, as given in Theorem C.1:
In other words, if neuron wins the lottery ticket at random initialization, then eventually, it will deviate from random initialization and grow to a feature that is more close to (a scaling of) . Our other main observation is that if we slightly over-parameterize the network with , then for each , and . Or in words, for each dimension , the number of lottery tickets across all neurons is at most , but at least one neuron will win a lottery ticket (see Lemma B.2). We also illustrate the lottery ticket winning process experimentally in Figure 8.
2 The Formation of “Dense Mixtures” During Training
The next phase of our analysis begins when all the neurons already won their lottery tickets near random initialization. After that, the loss starts to decrease significantly, so the (clean) classification error starts to drop. We shall prove that in this phase, gradient descent will also accumulate, in each neuron, a small “dense mixture” that is extremely vulnerable to small but adversarial perturbations. To show this, we maintain the following critical property as given in Theorem C.2:
If a neuron wins the lottery ticket for feature near random initialization, then it will keep this “lottery ticket” throughout the training.
Or in math words, for each neuron , after becomes sufficiently larger than all the other at the first stage, it will stay much larger than other for the remaining of the training process. To prove this, we introduce a careful coupling between the (directional) gradient of the neuron, and the (directional) Lipschitz continuity of the network , this is given in Section C.4.2.
The vulnerable dense mixtures. The most critical observation in this phase is the formation of “dense mixtures”, where we show that even for the “lucky neuron” that wins the lottery ticket, the hidden weight of this neuron will look like (see Theorem 5.2)
In other words, up to scaling, these neurons will look like , where is a “dense mixture” .
The key observation is that is small and dense, in the sense that it is a mixture of all the other features , but each of the feature has a much smaller contribution comparing to the leading term . Recall in our sparse coding model, each input ; so with high probability:
This value is even smaller than when . Thus, this dense mixture will not be correlated with any particular natural input, and thus the existence of these mixtures will have negligible contribution to the output of on clean data.
However, if we perturb input along the dense direction , we can observe that:
Comparing this with Eq (6.2), such “dense perturbation” can change the output of the neural network by a lot, using a small whose norm is much smaller than that of . Thus, at this phase, even when the network has a good clean accuracy, it is still non-robust to these small yet dense adversarial perturbations. Moreover, this perturbation direction is “universal”, in the sense that it does not depend on the randomness of the model at initialization, or the randomness we use during the training. This explains transfer attacks in practice: that is, the adversarial perturbation found in one model can also attack other models that are independently trained.
Feature purification. Since Eq. (6.2) suggests most original inputs have negligible correlations with each dense mixture, during clean training, gradient descent will have no incentive to remove those mixtures. Thus, we have to rely on adversarial training to purify those dense mixtures by introducing adversarial examples. Those examples have correlation with ’s that are higher than usual. As we prove in Theorem 5.1 and illustrate in Figure 1, such “purifications”, albeit imposing only a small change to each neuron, will greatly improve the robustness of the neural network.
The formation of the dense mixtures. To further help the readers understand how those “dense mixtures” are formed, we sketch the proof of Theorem 5.2, which shows why clean training is provably non-robust. The main observation is that when the dense mixtures are small, the negative gradient of the (say, population) loss with respect to each neuron is approximately given by (recall ):
We emphasize that this is indeed a special property of gradient descent. Consider again the case discussed in Section 3, where with . With high probability, a linear classifier using direction cannot be used to classify correctly. Yet, this direction is still locally positively correlated with the labeling function , especially for well-trained, well-generalizing neural networks when the can be “de-noised”. (Stochastic) gradient descent, as a local update algorithm, only exams the local correlation between the update direction and the labeling function, and it does not exam whether this direction can be used in the final result. Thus, this dense direction will be accumulated step by step, leading to a non-robust part of each of the features during clean training. In fact, even if we use as initialization as opposed to random initialization, continuing clean training will still accumulate these small but dense mixtures. We illustrate this in Figure 9.
Conclusion
In this paper, we made a first step towards understanding how, in principle, the features in a neural network are learned during the training process, and why after clean training, these provably well-generalizing features are still provably non-robust. Our main conclusion is that during the clean training process using (stochastic) gradient descent, neural network will accumulate, in all features, some “dense mixture directions” that have low correlations with any natural input, but are extremely vulnerable to (dense) adversarial perturbations. During adversarial training, such dense mixtures are purified to make the model more robust. Our results suggest that the non-robustness of clean training is mainly due to two reasons:
the inductive bias of (stochastic) gradient descent, and
the “sparse coding” structure of the data.
Both reasons are necessary in some sense. First, a robust model is also a global minimizer of the clean training objective (at least in our setting); but even with proper regularization and infinite training examples to avoid over-fitting, gradient descent still has inductive bias towards finding a non-robust model. Second, it is easy to come up with data sets— such as linear-classifier labels over well-conditioned mixture-of-Gaussians like inputs— where clean training using gradient descent directly achieves the best robust accuracy. Thus, to understand the non-robustness of neural networks, we more or less have to take into account the gradient descent algorithm and the structure of the inputs.
Indeed, our step is still very provisional. We immediately see a plethora of extensions from our work. First of all, natural images have much richer structures than sparsity; hence, those “non-robust mixtures” accumulated by clean training might also carry structural properties other than density. Moreover, we would like to extend our work to the clean and robust training of multi-layer neural networks, possibly with hierarchical feature purification processes. (Our experiments in Figure 10 have confirmed on such hierarchical feature purification phenomenon.) Indeed, understanding the whole picture of adversarial examples and adversarial training might require a complete understanding of deep learning.
Experiment Details
We perform experiments using three standard architectures, AlexNet, ResNet-16, and ResNet-34 with basic blocks, and tested on the CIFAR-10 dataset.We used the implementations from https://github.com/bearpaw/pytorch-classification. We used their default random crop and random flip as data augmentation.
We discover that learning rate for good for ResNet and is good for AlexNet; while weight decay is good for ResNet and is good for AlexNet (this was also recommended by the git repo authors). We use standard SGD with 0.9 momentum as the training algorithm. During adversarial training, we have implemented:
In Table 1, we present robust/clean accuracies against such attackers after vanilla clean training / vanilla adversarial training. We emphasize here that, in practice, one can also first perform clean training and then apply adversarial traing using the clean-trained weights as initialization (like we have theoretically studied in this paper). This does not affect the overall performance of both robust and clean accuracies.
Visualizing the first layer of any trained architecture is trivial: for instance, for AlexNet, the weight tensor of the first layer is which gives the RGB color of patches (and this was precisely what we presented in Figure 1). However, such visualization can be less meaningful for ResNet because the tensors are of dimension .
Visualizing the features presented by deeper convolutional layers is an active research area, dating back at least to . Perhaps the most naive approach is to start from a randomly initialize image (of size ), then take a specific neuron at some layer, and repeatedly take its gradient with respect to the image. If we keep adding this gradient to the input image, then ideally this gives us the image which “excites” the most. Unfortunately, it is a common knowledge in this area that this naive approach does not lead to “visually meaningful” images as we go (even slightly) deeper into a network (see e.g. the left column of Figure 10).
In existing literature, researchers have tried to various ways to resolve this issue (see e.g. an extensive survey by Olah et al. and the references therein). At a high level, some penalizes the image to remove high-frequency noise ; some searches for images that can still excite the given neuron after jittering ; and some searches only in the space of “real data” by building a model (e.g. using GAN) to capture the prior .
We observe that, if the model is robustly trained, then one can directly apply the naive approach to visualize features of the deep layers, and the resulting images can be “visually very meaningful.” See Figure 10.This should not be surprising given that the “jittering” technique is known to work in practice on visualizing clean models. Our theory in fact explains this phenomenon: the dense mixtures accumulated during clean training are extremely harmful to the visualization effect, since they are “visually meaningless.” After robust training, such dense mixtures are removed so the visualization starts to align better with human concepts.
Throughout this paper we stick to this naive approach for visualizing features of deep layers.Specifically, starting from a random input image, we take 2000 gradient steps to update the image so that the given neuron at a specific layer is excited the most. We added a weight decay factor to incentivize the image to go to RGB (128,128,128) — except in Figure 6 we incentivize the image to go to RGB (0,0,0).
2 Feature Purification at Deeper Layers
(stage 1) perform epochs of adversarial training;
3 Sparse Reconstruction of Input Data and of Adversarial Perturbation
Perhaps more importantly, our theory suggests that for clean-trained models, adversarial perturbations (we refer to as clean_delta) have “dense mixtures”; while for robust-trained models, adversarial perturbations (we refer to as robust_delta) are “more pure.” This was visually illustrated in Figure 7. Now, to better quantify this observation, we compare how sparse clean_delta and robust_delta can be reconstructed from robust features. See the second row of Figure 12.In fact, we have also re-scaled the perturbations so that they have similar mean and standard deviations comparing to real input images. This allows one to also compare the two rows of Figure 12. From this experiment, we confirm that in practice, adversarial perturbations on robust models are more “pure” and closer to real input images.
We point out when comparing how sparse clean_delta and robust_delta can be reconstructed from robust features, we did not cheat. For instance, in principle clean_delta may not lie in the span of robust features and if so, it cannot be (sparsely) reconstructed from them. In our experiments (namely, the second row of Figure 12), we noticed that clean_delta almost lies in the span of robust features (with regression error for AlexNet and for ResNet).
4 Comparing Different Attackers
We also demonstrate in Figure 13 that feature purification occurs against several different attackers.
5 Feature Purification is a Low-Rank Update
Recall from Theorem 5.2 and illustrated in Section 6.2 that the non-robustness of neurons in a clean-trained model, only comes from a common dense mixture direction . This suggests, during the robust (e.g., adversarial) training, we do not need to re-train all the parameters; it suffices to search only for a hidden mixture direction. We use experiments to support this finding.
Before we do so, please note we derived this “common dense direction” theory using a two-layered, binary classification setting. When there are multiple classes, one would expect there to be more dense mixture directions. In such a case, “low-rank update” is a more suitable choice.Specifically, consider a Conv2D unit of kernel size from in-channels to out-channels, its weight matrix (tensor) is of dimension . When performing a rank- update to it, we can construct two other Conv2D units, of dimension , and of dimension . Now, during adversarial training, we perform low-rank update by fixing to be the clean-train parameters, and only letting be trainable. For simplicity, we use zero initialization for and Gaussian initialization for , to ensure a smooth transition between clean and adversarial training. As for parameters, for this simple illustration we did not tune much, and simply set for learning rate and 5e-5 for weight decay. Both of them are just slightly smaller than the commonly used choices (for training ResNet) as we now have much fewer number of trainable parameters.
Now on CIFAR-10, we compare clean training, (traditional) adversarial training, as well as first conducting clean training and then performing an adversarially trained, low-rank update on all the convolutional parameters. We use the (pre-activation) ResNet-28 architecture as well as its widened versions ResNet-28-3/5/10 . Recall ResNet-28- has three groups of basic convolutional layers, each of and channels respectively.
We use “rank ” to denote a rank- update to all of the convolutional parameters.
We use “rank ” to denote rank-, , updates respectively to the convolutional parameters in the three groups.
We present our findings in Figure 14. For example, for the ResNet-28-10 model:
Using the clean-trained model weights alone, the robust accuracies are zeros.
Now, on top of such clean-trained weights, barely training a rank-1 (or rank ) update for each convolutional matrix, or equivalently only about (less than 1 percent) of the parameters, one can already recover more than 80% of the maximum robust accuracy.
Similarly, in the “rank ” case we train only about of the parameters, one can recover more than 90% of the maximum robust accuracy.
We believe this preliminary experiment can be useful in supporting our theory, and may be of independent interests for other applications. (Indeed, in a follow-up work we found an application of such low-rank update to language model fine-tuning .)
We give a quick overview of the structure of our appendix sections.
In Section A, we warm up the readers by calculating the gradient of the objective, and demonstrating that polynomially many samples are sufficient for the training.
In Section B, we formally introduce , the set of “potentially lucky neurons” and , the set of “surely lucky neurons” at iteration . In particular, we shall emphasize on how those notions evolve as increases.
In Section C, we formally prove how “lucky neurons” continue to be lucky, and more importantly, for every neuron that is lucky in direction , why it grows faster than other unlucky directions , and how much faster. Specifically, Theorem C.1 corresponds to the initial “lottery-winning” phase where the accuracy remains around ; and Theorem C.2 corresponds to the later phase where large signals become even larger and eventually most neurons become “pure + dense mix” of the form (6.1). This is the most difficult section of this paper.
In Section D, we prove that why clean training gives good clean (testing) accuracy. It is based on the structural theorem given by Theorem C.2, and requires some non-trivial manipulations of probability theory results (such as introducing a high-probability, Bernstein form of the McDiarmid’s inequality).
In Section E, we prove that why the model obtained from clean training is non-robust. It formally shows how the “dense mixtures” become accumulated step by step during clean training.
In Section G, we prove lower bounds for the neural tangent kernel model given by two-layer networks.
In Section H, we give missing details of some probability theory lemmas.
Appendix A Notations and Warmups
We find it perhaps a good exercise to do some simple calculations to warmup the readers with our notations, before going into the proofs.
Global Assumptions. Throughout the proof,
We choose for a very small constant .
(One should think of for a simple reading. Our proof generalizers to larger since having more neurons does not hurt performance, but we ignore the analysis so as to provide the simplest notations.)
We choose for simplicity.
(The purpose of factor is to simplify notations, and it can be tightened to constant.)
Whenever we write “for random ”, “for random ” or “for random ”, we mean that the come from the distributions introduced in Section 2 with .
Suppose are i.i.d. samples from and , and suppose for some sufficiently large polynomial. Let and suppose and . Then, for every that may depend on the randomness of and satisfies , it satisfies
In addition, suppose for every , we have an i.i.d. random sample that is independent of and . Then, with probability at least over , we have
The proof of the second part can be done by trivial Hoeffding bounds. ∎
Appendix B Neuron Structure and Initialization Properties
We consider for a very small constant , and consider constants to be chosen shortly. Let us define a few notations to characterize each neuron’s behavior.
Recall is the weight for the -th neuron at iteration . We shall choose a parameter at each iteration and define the following notions. Consider any dimension .
Let be those neurons satisfying
,
for every ,
.
Let be those neurons satisfying
Let be the set of neurons satisfying
for at most many .
for at most many .
for at least many .
Suppose each and suppose . For every constants and , by choosing and , we have with probability over the random initialization, for all :
Recall is the bias at iteration , and let us introduce more notions.
Let be the set of neurons satisfying
,
for at most many .
Let be the set of neurons satisfying
Let be the set of neurons satisfying
.
Let be the set of neurons satisfying
,
.
Note that we do not have good properties on , , or at initialization ; however, they will gradually begin to satisfy certain properties as the training process goes. See Section C for details.
Recall if is standard Gaussian, then for every ,
Therefore, for every and ,
We first lower bound . For every , with probability at least it satisfies
By concentration with respect to all choices of , we know with probability at least it satisfies .
We next upper bound . For every , with probability at most it satisfies
By concentration with respect to all choices of , we know with probability at least it satisfies .
As for , we first note that for every , by chi-square distribution’s tail bound, with probability at least it satisfies .
For every , the probability of existing different
is at most . Union bounding over all possible gives the proof that, with probability at least , for all but at most values of , it satisfies .
For every and , with probability at least it satisfies . Therefore, with probability at least , there are indices satisfying .
For every and , with probability at least it satisfies . Therefore, with probability at least , there are indices satisfying . ∎
Appendix C Neuron Structure Change During Training
For analysis purpose, we consider two phases during training. In Phase I, the neurons have moved so little so that the accuracy remains for binary classification; however, some neurons shall start to win lottery and form “singleton” structures. We summarize this as the following theorem.
for every .
for every .
and for every at this iteration .
(Recall according to Definition B.1 we have .)
In Phase II, the neurons start to move much more so that the network output becomes more meaningful; in phase II, the “singleton” neurons become even more singleton.
In the same setting as Theorem C.1, with probability at least , the following holds for all t\in\big{[}T_{\mathsf{b}},\,d^{O(\log d)}/\eta\big{]}.
.
for every .
for every .
(Recall according to Definition B.3 we have .)
Theorem C.2 immediately implies the first claim of Theorem 5.1 and the first claim of Theorem 5.2, after plugging in the definitions of those neuron structure sets introduced in Section B. For instance, we can write
We make several observations, when :
implies the cardinality of is , so we can define it as .
For every , it also satisfies , so we have (using from Definition C.12).
For every , we have (using from Definition C.12 and our choice of ).
They together imply the first claim of Theorem 5.2. One can similarly derive the first claim of Theorem 5.1.
We present a lemma to bound the size of the pre-activation signal.
For every , every , every , every :
Let be the event where there exists with and . Again, by the definition of , we know that
Thus, when neither or happens, we have for every :
Apply Bernstein concentration bound we complete the proof that
Finally, for the part, let us recall variable with variance at most and each w.h.p. Using Bernstein concentration of random variables, we finish the proof. ∎
Let be the event where there exists with and . By the definition of , we know that
When does not happen, we have for every : and at the same time
Apply Bernstein concentration bound we complete the proof that
Finally, for the part, let us recall is a random variable with variance at most . Using the Bernstein concentration bound, we finish the proof. ∎
C.2 Auxiliary Lemma 2: A Critical Lemma for Gradient Bound
In this section we present a critical lemma that shall be used multiple times to bound the gradient in many of the following sections. Recall is a constant from Lemma B.2.
For every , suppose , define quantity
it always satisfies
Furthermore, suppose we can write and for and being independent (although may be dependent, and may be dependent). Then, we have
if , then
and
We first focus on , and write
Focusing on the term , by the symmetric properties of and , we have
so we can go back to (C.1) (and repeating for ) to derive that
This proves Lemma lem:criticalb. Finally, when , we can bound differently
To bound the first term in (C.4) we consider two cases.:
when , we have ;
when (happening w.p. ), we have \operatornamewithlimits{\mathbf{Pr}}_{\rho}[\rho\in[b-S_{2}-\alpha,b-S_{2}+\alpha]]\leq\min\{1,O\big{(}\frac{\alpha}{\sigma_{\rho}}\big{)}\}.
To bound the second term in (C.4), first recall and , so we can write
To bound the first term in (C.6), we can take expectation over and use the bound to derive
but since and , we can further bound
Putting (C.5) and (C.7) back to (C.4), we conclude the when , we have
C.3 Phase I: Winning lottery tickets near initialization
In Phase I.1, we pick and
We grow for iterations.
In Phase I.2, we pick and
We grow for iterations.
Recall . Recall also is a constant from Lemma B.2.
We define to be any value such that
\operatornamewithlimits{\mathbf{Pr}}_{x}\left[\big{|}\big{\langle}w_{i}^{(t)},\sum_{j^{\prime}\not=j}\mathbf{M}_{j^{\prime}}z_{j^{\prime}}+\xi\big{\rangle}\big{|}\geq\frac{c_{2}}{10c_{1}}b^{(t)}\right]\leq\Gamma_{t} for every and ;
\operatornamewithlimits{\mathbf{Pr}}_{x}\left[\big{|}\big{\langle}w_{i}^{(t)},x\big{\rangle}\big{|}\geq\frac{c_{2}}{10c_{1}}b^{(t)}\right]\leq\Gamma_{t} for every
for every
We define to be any value such that
for every and , there exists with satisfying
If we are in Phase I.1 and , then we can choose and .
If we are in Phase I.2 and , then we can choose and .
Recall . Applying Lemma lem:geo:0a and Lemma lem:geo:0b we immediately have
If , then ;
If , then .
Now, recall so it differs from only by one term. Therefore, we have the same bound on by modifying the statements of Lemma lem:geo:0a and Lemma lem:geo:0b (without changing the proofs) to include this missing term.
If ,
If ,
At the same time, using , we also have
In Phase I.1, because , we have
In Phase I.2, because , we have
C.3.2 Growth Lemmas
Our first lemma here shall be used to (lower) bound how (i.e., the weight with respect to neuron in direction ) grows for those .
Suppose we (1) either are in Phase I.1 with , (2) or are in Phase I.2 with . Then, for every , every , as long as , the following holds:
Recall that means . Without loss of generality, let us assume .
First consider the case when . Since , we have so applying Lemma C.7,
For all other non-zero value , we have and wish to apply Lemma C.5 to bound
In Phase I.1, to apply Lemma C.5, we choose parameters as follows:
, , , , ,
let be the subset defined in Lemma C.7, then we can let and
we have (from Lemma C.7) and
where inequality ① uses Lemma lem:sba and from Lemma C.7.
and when
when (which implies )
In Phase I.2, the analysis is similar with different parameters: in particular,
and when
when (which implies ).
(This uses and .)
Taking expectation over as before, and using finishes the proof. ∎
Our next lemma shall be used to upper bound how can grown for every .
Suppose we (1) either are in Phase I.1 with , (2) or are in Phase I.2 with . Then, for every , every , the following holds:
Proof is analogous to that of Lemma C.8, and the reason we no longer need the requirement is because, when invoking Lemma C.5, it suffices for us to apply Lemma lem:criticala for every non-zero values of (as opposed to only those z=\Omega\big{(}\frac{1}{\log\log\log d}\big{)}) which no longer requires . ∎
Our next lemma shall be used to upper bound how can grown for every .
Suppose we (1) either are in Phase I.1 with , (2) or are in Phase I.2 with . Then, for every , every , the following holds:
where is given from Lemma C.7.
Suppose and without loss of generality . We choose as before. Then, we have always holds.
Therefore, using the same notation as the proof of Lemma C.8, we always have the bound
Plugging in the parameters we finish the proof. ∎
Our final lemma shall be used to upper bound how can grown with respect to the noise in the input.
For every , every , the following holds:
We can define and study
when , ;
when (which happens with exponentially small prob.), .
C.3.3 Proof of Theorem C.1
Suppose in Lemma C.8 the hidden constant is for the lower bound, that is,
Let us prove by induction with respect to . Suppose the properties all hold at . Recall from Fact A.1, for iteration , for every neuron ,
Together, we have a clean formulation for our gradient update rule:
We now prove each statement separately (and note our proofs apply both to Phase I.1 and I.2).
For every , by substituting Lemma C.10 and Lemma C.11 into (C.9), we have
so we also have and thus .
For every , suppose wlog is positive. Then, either in such a case we still have . Otherwise, if then by substituting Lemma C.8 and Lemma C.11 into (C.9), we have (using and )
so by induction we also have . Combining this with , we conclude that .
To check , we need to verify four things:
for at most many .
This is so because and .
for at most many .
This can be derived from (C.10) in the same way.
for at least many .
This can be derived from (C.10) in the same way.
For every , suppose wlog is positive. Then, by substituting Lemma C.9 and Lemma C.11 into (C.9), we have
Applying this formula for times, we derive that
and therefore applying this together with (C.10),
(Above, inequality ① uses that there are at most indices such that .)
Finally, to check for , we first derive that
For every , (C.10) gives
In particular, this together with ensures that for every , for at most many .
For any , using (C.11) we have
Using this together with the previous item, as well as , we have .
Putting them together we have for every .
After iterations, we have , for every , by Lemma C.10 and Lemma C.11
Combining this with (C.11), we immediately have
This implies and at this iteration .
C.4 Phase II: Signal Growth After Winning Lottery
In phase II we make the following parameter choices.
In Phase II, we pick and .
We grow as before (the same as phase I.2 in Definition C.6) for each iteration, but stop growing when it reaches a threshold .
We first introduce a notation on a (high-probability) version of the coordinate Lipscthiz continuity.
At every iteration , for every , we define to be the smallest value such that w.p. at least over the choice of and , for every and , , and :
In this subsection, we provide new growth lemmas Lemma C.14, Lemma C.15, Lemma C.16, Lemma C.17 that are specific to Phase II, to replace the user of the old growth lemmas Lemma C.8, Lemma C.9, Lemma C.10, Lemma C.11 from Phase I.
Suppose we . Then, for every , every , the following holds:
First, without loss of generality, assuming that . Let us define and . Define
Now, since is an -Lipschitz function in , we know that w.p. at least
Let us first focus on the case that . As before, since , we have so applying Lemma C.7,
Now recall .
Combining this with (C.13), and using finishes the proof. ∎
Suppose we . Then, for every , every , the following holds:
Suppose we . Then, for every , every and , the following holds:
In the same notation as the proof of Lemma C.14, we have
where the last inequality uses Lemma C.7 and the fact (which, as before, implies if we choose then \alpha^{2}\leq(c_{1}-c_{2})(\sigma_{w}^{(t)})^{2}\log d\leq\big{(}\frac{b^{(t)}}{4}\big{)}^{2}).
Since , Lemma C.5 tells us
Combining this with (C.13), and using finishes the proof. ∎
Finally, we derive a more fine-grind bound for the noise:
Suppose we . Then, for every ,
suppose also for every , then
We can first decompose the noise into
Let us define .
On one hand we have with probability at least , (using a variant of Lemma C.7). Using the randomness of and we also have with probability at least it satisfies . Therefore, with probability at least , we have .
Otherwise, in the event that , using the randomness of , we have that
Using the coordinate Lipscthizness, we also have
Next, we want to prove Lemma lem:noise2b. We have: denote
Since w.p. at least , , in this case, we know that
Next, similar to the (C.14), we also have
Combining (C.16) and (C.17) we finish the proof of Lemma lem:noise2b.
C.4.2 Growth Coupling
We also have the following lemma which says, essentially, that all those neurons satisfying for the same , grows roughly in the same direction that is independent of .
Suppose at iteration , . Then, for every , every such that , we have:
We first focus on the case when is positive, and the reverse case is analogous. Conditional on , we know that . Thus, when , . Now, using and Lemma C.7, we can conclude that
when , ;
when , .
C.4.3 Activation Probabilities
Suppose and for every . Then, with probability at least ,
for every .
For every and with , we have . Therefore, by Bernstein’s inequality (similar to Lemma lem:geo:0b), we know with probability at least , for every ,
With probability at least it satisfies (since each with probability at most ). Therefore, denoting by , we have (since every ). Now, for any , inequality (C.18) immediately gives
Therefore, the number of satisfying cannot be more than . ∎
C.4.4 Coordinate Lipscthizness Bound
For every , let us define . Then, suppose and suppose , we have
By Lemma C.19 and the randomness of , we know with probability at least , the number of activate neurons —meaning or — is at most . On the other hand, when , we know that
Therefore, together, the total contribution from these active neurons with is at most . This completes the proof. ∎
C.4.5 Regularization
Following the same argument as (C.9) from phase I, we know at any iteration , as long as ,
In this and the next subsection, we shall repeatedly apply growth lemmas to (C.19). Before doing so, let us note , so using our parameter choice of and using ,
This means, when applying the aforementioned growth lemmas Lemma C.14, Lemma C.15, Lemma C.16, the additional terms and are negligible.
We also have the following regularity lemma:
For every , suppose and hold for every and . Then, we have for every , with probability at least ,
By substituting Lemma C.15, Lemma lem:noise2a and (C.20) into (C.19), we have for every :
Summing up over all , and using Cauchy-Schwarz inequality together with , we have
Combining this with from Lemma C.20 and our choice , we have (for every and ),
This also implies as well as
Finally, for the objective value, we wish use and apply a high-probability Bernstein variant of the McDiarmid’s inequality (see Lemma H.3).
Specifically, consider random . For notation simplicity, let us write for i.i.d. random .
Now, for every , suppose we change to and to with the same distribution. Then, with probability at least ,
This implies with probability at least ,
Therefore, we can apply Lemma H.3 to derive that with probability at least ,
We also prove this Lemma, which gives a lower bound on the loss:
In every iteration , define and suppose . Then we have:
Let \alpha\in\big{[}\frac{1}{(\Xi_{2})^{5}},1\big{]} be a fixed value to be chosen later, and be an arbitrary subset of size . Consider a randomly sampled vector and let be the corresponding input. We construct another that is generated from the following process
Let be the set consisting of all with .
For all , pick .
For all , pick or each with probability , independently at random.
Obviously, has the same distribution as . Now, let us define , .
Since , recalling the distribution property that , we know with probability at least over the choice of , . We call this event .
Let us denote by for every . We can therefore write to emphasize that the randomness comes from . Using the definition of coordinate Lipscthizness, we know with probability at least over , it satisfies
Let denote the event where the above statement holds.
Now, conditioning on and both hold, we can apply standard MiDiarmid’s inequality (see Lemma H.2) over the randomness of , and derive that with probability at least over ,
Let denote the (conditional) event where the above statement holds.
In sum, by combining , we know with probability at least over , it satisfies
As a simple corollary, if we generate another copy in the same way as , and denote by , then with probability at least over , it satisfies
Now, let us denote by and and compare them. Let us write
Thus, we have and .
First using a minor variant of Lemma lem:sbb, we have To be precise, we can do so since we still have at least coordinates.
Denote this event by .
Next, conditioning on any fixed which satisfies and , we know that and become independent, each controlled by random Bernoulli variables. Therefore, we can apply a Wasserstein distance version of the central limit theorem (that can be derived from , full statement see [6, Appendix A.2]) to derive that, for a Gaussian variable where , the Wasserstein distance:
This means with probability at least , it satisfies and .
To sum up, we know with probability at least , it satisfies and . This means , or in symbols,
Finally, conditioning on both (C.21) and (C.22) happen, we know that
C.4.6 Proof of Theorem C.2
We first prove that for every ,
Note from the definitions the relationship always holds, so we only need to prove the second inclusion.
Suppose (C.23) holds until iteration . Then, for every , let us apply Lemma C.16, Lemma lem:noise2a together with (C.20) and (using Lemma C.21) to (C.19). We get
Therefore, for those that are sufficiently large so that , we have (using )
and for those that are still small so that , we have
Together, this means so (C.23) holds for all and .
Phase II.1. We will construct a threshold and prove inductively for all . Initially at , by Lemma C.20 we have . As long as holds for all , we have
for every , substituting Lemma C.15, Lemma lem:noise2a and (C.20) into (C.19),
for every , substituting Lemma C.16, Lemma lem:noise2a and (C.20) into (C.19),
Since for each , the number of satisfying is at most (using and ), we have
These bounds together mean several things:
for all and with .
Indeed, (C.24) gives , but the number of satisfying is at most . So we can apply Lemma C.20 to get .
for all .
for those that are small so that , we have (C.24) implies ; and
for those that are large so that , we have (C.24) implies .
Together we have .
for all .
This is a direct corollary of together with the property that the number of satisfying is at most .
Next, let us consider any with . At any iteration , substituting Lemma C.14, Lemma lem:noise2a, (C.24), and (C.20) into (C.19),
The value keeps increasing as increases, until it reaches and at that point it may decrease but will not fall below . This ensures .
At , we must have because
To sum up, at iteration , we have
for , ;
for ,
for ,
Phase II.2. We first make a quick observation that
for all .
Indeed, from iteration on, we have . Using Lemma C.21 we have for every , . Thus, holds for all . As for , it is a simple corollary of together with the property that the number of satisfying is at most .
Next, we claim for every and every , it must hold that
for some sufficiently large constant . We prove by induction. Suppose (C.25) holds for and we consider . By the definition of , we know . Now, consider every other
if , then after one iteration we still have .
if , then we have
Therefore, applying Lemma C.18 and Lemma lem:noise2a (for and ), and using , we have
Taking the difference and using (C.26), we have
thus we continue to have .
Putting these together we show that the first half of (C.25) holds at .
As for why , we consider two cases.
If , then in one iteration we should still have .
If , then by the first half of (C.25) together with Lemma C.20, we know the Lipscthizness . In this case, we also have (see (C.26)) . Applying Lemma C.14 and Lemma lem:noise2a again we have
Putting both cases together we have so the second half of (C.25) holds at .
Appendix D Clean Accuracy Convergence Analysis
In this section we show the upper bound on how the clean training of a two-layer neural network can learn the labeling function from training samples up to small generalization error.
Our convergence analysis will rely on the following (what we call) coupling function which is the first-order approximation of the neural network.
At every iteration , we define a linear function in
and it equals the output of the real network at point both on zero and first order:
In the analysis, we shall also identify a special choice defined as follows.
Recall are disjoint, so we construct by
Above, is a parameter to be chosen later. One can easily check (using Lemma B.2) that
and
More interestingly, our so-constructed satisfies (to be proved in Section D.2)
Suppose , and for every . Then,
with probability at least over ,
We are now ready to prove Theorem D.1. Since , we have the identity
which is a convex function in because is linear in . We have, for every ,
Above, ① uses the definition of , ② uses Lemma lem:g-coupling:baseb (and Theorem C.2 for the prerequisite for Lemma lem:g-coupling:baseb), and ③ uses Claim D.5 for the bound on and .
Therefore, after telescoping for , and using , we have
and this finishes the proof.
D.2 Proof of Claim D.6: Main Coupling
The proof of Lemma lem:g-coupling:basea comes from Claim D.7 and Claim D.8 below. In the two claims, we split into two terms, and bound them separately. Define
Recall for each ,
it satisfies so ;
it also implies for any , so ;
recall for .
recall is a variable with variance at most for .
Applying Lemma C.19, we know with probability at least it satisfies
and when this happens it satisfies, whenever ,
Summing up over all and , we have with probability at least over : . ∎
Let us write where each is i.i.d. Let us write
We note that is a random variable that depends on independent variables
so we also want to write it as and .
We can without loss of generality assume as if and always hold, both of which happen with probability at least . In the rest of the proof we condition on this happens. By symmetry we have
We wish to apply a high-probability version of the McDiarmid’s inequality (see Lemma H.3) to bound . In order to do so, we need to check the sensitivity of regarding every random variable.
For every , suppose we perturb it to an arbitrary . We also write and .
Now, for every , we have the naive bound
and there are at most such neurons .
For every , we have . Define event
When event does not happen, we have , and thus
When happens, using the randomness of , we have
Note with probability at least , the number of with holds is at most (using Lemma C.19). Therefore, by applying Chernoff bound, we know
This means two things that both hold with probability at least over :
For all ,
For every , suppose we perturb it to . We write and .
Now, for every , with probability at least we have . Therefore, if it also happens that , then . In other words, we have
Summing up over , and taking expectation in , we have
where the last inequality uses a variant of Lemma C.7 and .
For every , we have . Define event
When event does not happen, we have , and thus
When happens, using the randomness of , we have
Note with probability at least , the number of with holds is at most (using a minor variant of Lemma C.19). Therefore, by applying Chernoff bound, we know with probability at least over
Taking expectation over , we have with probability at least over :
Putting the two cases together, we have with probability at least over :
This means two things that both hold with probability at least over :
We are now ready to apply the high-probability version of the McDiarmid’s inequality (see Lemma H.3). We apply it twice. In the first time, we use the perturbation on to derive that, with probability at least over :
In the second time, we use the perturbation on to derive that, with probability at least over ,
This finishes the proof of Lemma lem:g-coupling:basea. We are only left to prove Lemma lem:g-coupling:baseb.
By Lipscthiz continuity of the function, we know with probability at least ,
Taking expectation (and using the exponential tail) we have
Note if we take expectation over , we have
where ① uses Lemma lem:sba. This finishes the proof of Lemma lem:g-coupling:baseb.
Appendix E Why Clean Training is Non-Robust
The proof of Theorem E.1 relies on the following main lemma (to be proved in Section E.1). It says that towards the end of clean training, neurons have a (small) common direction in .
With the help of Lemma E.2, one can calculate that by perturbing input in this direction , the output label of the network can change dramatically. This is the proof of Theorem E.1 and details can be found in Section E.2.
Before proving Lemma E.2, let us first present Claim E.3.
Applying Lemma lem:noise2b and using and (see Lemma C.21), we have
Using , and a similar analysis to Lemma C.19, we know with probability at least it satisfies . Therefore, the above inequality gives
Now, using small ball probability Lemma lem:sba we have
where the last inequality ① uses Lemma C.21 and Lemma C.22.
Therefore, using , we have
so we conclude for every it satisfies
E.2 Proof of Theorem E.1
Therefore, setting for some , and using (since ), we have . Using this, we can sum up over all :
where is the unique index such that . We can rewrite the decrement
Using and \big{(}\mathds{1}_{w^{\star}_{j}z_{j}>0}+\mathds{1}_{w^{\star}_{j}z_{j}<0}\big{)}=1 with probability , we can apply Bernstein’s inequality and derive
Also using \big{(}\mathds{1}_{w^{\star}_{j}z_{j}>0}+\mathds{1}_{w^{\star}_{j}z_{j}<0}\big{)}=1 with probability , we can derive using Lemma E.2 that
Combining the above equations and using , we have with probability at least ,
For the remainder terms, we using , we have
Using Lemma E.2 and Lemma C.19 we have with probability at least ,
Putting together the bounds for and we have
In other words, choosing , then combining with from Lemma C.21, we immediately have .
Using an analogous proof, one can also show that . Therefore, if we choose a perturb direction , we have
This means the robust accuracy is below . Finally, using and finishes the proof.
Note that a similar proof as above also shows
Appendix F Robust Training Through Local Feature Purification
Suppose we run clean training for iterations following Theorem D.1. From this iteration on, let us perform more steps of robust training.
During the robust training phase, let us consider an arbitrary (norm-bounded) adversarial perturbation algorithm . Recall from Definition 4.2 that, given the current network (which includes hidden weights , output weights , bias and smoothing parameter ), an input , a label , and some internal random string , the perturbation algorithm outputs a vector satisfying
for some . Then,
Consider for instance , , and sufficiently large .
for some . Then,
With additional efforts, one can also prove that Theorem F.1 and Theorem F.4 holds with high probability for all in the range . We do not prove it here since it is not beyond the scope of this paper.
We first note some simple structural properties that are corollaries of Theorem C.2.
At iteration , for every neuron , we can write
where with , and .
We can let and let be the remaining part. We have because . We have . We also have
We next introduce an important notation that shall be used throughout the proofs of this section.
F.2 Robust Coupling
At every iteration , recalling , we define a linear function in
and it equals the output of the real network at point both on its zero and first order:
We shall show in this section that, recalling , then
It is perhaps worth nothing that the “closeness” of the above terms depend on two things,
One is regarding how small is, and this shall later be automatically guaranteed via implicit regularization of first-order methods.
The other is regarding how small or is for every individual neuron . This is a bit non-trivial to prove, and we shall spend the entire Section F.3 to deal with this.
As a corollary, in the event of and and using , we have
Let us abbreviate the notations by setting and .
To upper bound it suffices to upper bound for
(and one also needs to take into account the reverse part, whose proof is analogous).
We first make some calculations. Using the definition of , we have for every . Thus, we can easily calculate that Here, the spectral norm bound of holds for the following reason. Each is a sparse vector supported only on coordinates, and thus holds for a diagonal matrix that where for and otherwise. Now, using the fact that , we immediately have that .
Case 1, and both happen. In this case, it must satisfy . . Also, with probability at least , it satisfies . To sum up, with high probability we have
Case 2, either or . In this case, to satisfy , one must have . Also, using the randomness of , we have
As a corollary, in the event of and using , we have
To upper bound it suffices to upper bound for
(and one also needs to take into account the reverse part, whose proof is analogous).
Let us define . By the properties that (1) is only supported on with , (2) for each at most of the are supported on , and (3) , we can obtain
Using a similar analysis to (F.4), we have
Above, inequality ① is due to a similar analysis as (F.6), and inequality ② is because with probability at least . Next, let us recall and thus, by Bernstein’s inequality, with probability at least ,
Combining the bounds on , , and finishes the proof. ∎
As a corollary, in the event of and and using , we have
The proof is analogous to Lemma F.11 so we only highly the differences. In fact, we only need to change (F.1), (F.2) and (F.3) with the following calculations.
Putting those into the rest of the proof (to replace (F.1), (F.2) and (F.3)) finishes the proof. ∎
As a corollary, in the event of and using , we have
The proof is analogous to Lemma F.12 so we only highly the differences. Recall we have defined
Let us define . By the properties that (1) is only supported on with , (2) for each at most of the are supported on , and (3) , we can obtain
F.3 Individual Neuron Growth Lemma
As a corollary, suppose we run robust training from iteration to with , and , then
First of all we can reuse the analysis of (F.4) and derive that
Using the property of we have for and therefore
Putting (F.7), (F.8), (F.9), (F.10) these together, we have
Now, suppose we run robust training for and suppose for all of them we have satisfied. Then, using the gradient update formula (see e.g. (C.19))
This means, in order to show we can choose any satisfying
Using the assumption of (which also implies ), (which also implies ), and , we can choose
As a corollary, suppose we run robust training from iteration to with and \tau\leq o\big{(}\frac{b^{2}}{T\eta\cdot k\Xi_{2}^{2}\|\mathbf{M}\|_{\infty}}\big{)}, then
Similar to the proof of Lemma F.15, and using , we have
Since with probability at least it satisfies , we can conclude that . Together we have
Now, suppose we run robust training for and suppose for all of them we have satisfied. Then, using the gradient update formula (see e.g. (C.19))
Recalling from (F.8), we have
This means, to prove that , we can choose any satisfying
and using the assumption of (which implies ), and \tau\leq o\big{(}\frac{b^{2}}{T\eta\cdot k\Xi_{2}^{2}\|\mathbf{M}\|_{\infty}}\big{)} (which implies ), we can choose
F.4 Robust Convergence
We are now ready to prove the main convergence theorem (that is, Theorem F.1 and F.4) for robust learning. Let us first calculate a simple bound:
Recalling and from Proposition F.8, we have
Since , we have the identity
Applying (a variant of) Lemma A.2 (which requires us to use the Lipscthiz continuity assumption on , see Definition 4.2), we know that by letting
Let us also define the clean objective and the pseudo objective as follows:
which is a convex function in because is linear in .
Now, we inductively prove that at every iteration , it satisfies
In the base case this is obvious due to Proposition F.8. Next, suppose (F.12) and (F.13) hold at iteration . Using the notation and the Lipscthiz continuity of , we have Note to apply Lemma F.11 we also need to check but this is automatically satisfied under our parameter choice .
Therefore, we can bound the left hand side of (F.11) as follows:
Putting this back to (F.11) and telescoping for for any , we have
so (F.12) holds at iteration . We can then also apply Lemma F.15 which ensures (F.13) holds at iteration .
Finally, let us go back to (F.14) and choose . It implies
Note that our final choice of also ensures that the pre-requisite and of Lemma F.15 hold. ∎
The proof is nearly identical to that of Theorem F.1. In particular, we want to inductively prove that at every iteration , it satisfies
We also need to redo the following calculations:Note to apply Lemma F.13 we also need to check but this is automatically satisfied under our parameter choice for .
F.5 Fast Gradient Method (FGM) Robust Training
This means for at least probability mass of inputs , we have
For those choices of , using the fact that is linear in , we also have
Therefore, for all of those (with total mass ) satisfying both, we can first apply (F.17) (with ) to derive
Applying (F.18) then we obtain (for any )
This means, the output of the network is robust at point against any perturbation with radius . We finish the proof of Corollary F.2. ∎
Recall from Definition 5.6 that the feature mapping of the neural tangent kernel for our two-layer network is
Therefore, given weights , the NTK function is given as
With probability at least it satisfies . When this happens, we must have . ∎
One can carefully apply the Taylor expansion of the smoothed indicator function (using the randomness of ), to derive the following claim. (Detailed proof in Section G.4.)
Consider any NTK function with parameters , , with and . Suppose , then there exists coefficients with
each ,
each ,
each for every odd constant
each .
so that, for every with and every with and , we have:
Using for odd constant , and , by applying Lemma G.4,Specifically, one should substitute \|v_{i}\|_{2}\big{(}c_{i,r}\frac{v_{i}}{\|v_{i}\|_{2}}+c^{\prime}_{i,r}\frac{w_{i}}{\|w_{i}\|_{2}}\big{)} as the new when applying Lemma G.4. we know that when (say wlog. is odd),
Also, for a parameter , let us apply Lemma G.5 to derive
Let be a constant to be chosen later, , and let be the choice of which maximizes the value of .
Consider the high probability event that , then using , we have
Next, for every , let us define
On one hand, by applying Lemma G.5 twice for each , we know for every set of vectors with and for , it satisfies
This means by Markov’s inequality, for at least fraction of the indices , denoting them by , it satisfies
On the other hand, by Claim G.7, we know that there is an such that
Without loss of generality, suppose is positive and .
Combining the two, when , we derive that for those ,
Thus, combining with (G.1), (G.2) and (G.3), we have for those ,
This finishes the proof of Theorem G.1
G.2 Tensor Lower Bound
Next, for each degree- homogenous part of the polynomial expansion of Claim G.3, we can write it as a tensor and lower bound its Frobenius norm as follows.
We have as long as , then w.p. over the randomness of , for every we have
Consider any fixed , and some to be chosen later.
Let us define which satisfies . We have
Note that for every , with probability at least ,
This implies that as long as ,
Since the above lower bound holds for every and every , we immediately know
This implies our bound on the Frobenius norm as well. ∎
G.3 Tensor Perturbation
We present the following critical lemma, which serves as the major step to prove the non-robustness of Neural Tangent Kernel:
For the first item, we can simply let . This choice of satisfies and with high probability. Furthermore, by applying anti-concentration of Gaussian polynomials (see for instance [5, Lemma I.1]), we know with at least constant probability . This proves the first item.
To see the second item, we first note by tensor -linearity and symmetry,
and therefore we only need to bound the terms on the right hand side for any fixed .
From these notions one can directly calculate that
On the other hand, we have and moreover, using the randomness of , we know w.h.p. for every . Hence, by Claim G.8, we know that
Putting them together, we have , and since this holds for every , we conclude that:
Putting this back to the binomial expansion finishes the proof. ∎
G.4 Smoothed ReLU Taylor Series: Proof of Claim G.3
We first note the following Taylor expansion formula for smoothed ReLU.
Let be any real and for . Then, for every ,
where
so using Taylor expansion of we prove the first equation. As for the second equation, we have
Using Taylor expansion and integrating once, we prove the second equation. ∎
Specifically, for each , denoting by , we wish to apply Claim G.6 to
We first deal with the part. Using Claim G.6, we have
for . Similarly, we also have
Putting them together, and using the fact that , we can write
for for every and .
Let us now focus on the part. Let be the part of that is parallel to . Then obviously we have
Above, the last ① is due to and .
for . Putting them together, and doing the same thing for the symmetric part, we have
Above, using the property of , equation ① holds for some and .
Finally, putting the bounds for and together, and using , we derive that
for for every , for every , and for every odd constant . This finishes the proof of Claim G.3. ∎
G.5 Simple Lemmas
We have the following claim relating polynomial value with its coefficients:
Conversely, by writing , we also have the other direction and therefore
Now, notice that , so we can apply Markov brother’s inequality to derive that
Using this Claim, we also have the following claim about symmetric tensor:
is obvious so let us prove the other direction. Define polynomial
The coefficient of at degree is . Thus, applying Claim G.7 and appropriately scaling the operator, we complete the proof. ∎
Appendix H Appendix for Probability Theory
For every subset , every , and every ,
For every subset with , and every ,
Recall we have for each . Let be the subset of such indices with non-zero , so by our assumption we have for each . By Chernoff bound, with probability at least , we know .
Conditioning on such , by the Littlewood-Offord problem (a.k.a. small ball probability theorem, or anti-concentration for sum of Bernoulli variables, see ), we know
Using the property of Gaussian variables and , we have
and using the above Wasserstein distance bound, we have
H.2 McDiarmid’s Inequality and An Extension
We state the standard McDiarmid’s inequality,
Consider independent random variables and a mapping . If for all and for all , the function satisfies
We prove a more general version of McDiarmid’s inequality,
Let be independent random variables and . Suppose it satisfies for every ,
with probability at least over , it satisfies
with probability at least over , it satisfies
For each , we have with probability at least over , it satisfies
We also have with probability at least over , it satisfies
We denote by the event (over ) that the above two statements hold. We know that . For notational simplicity, we denote by the full set over all possible .
Define random variable (which depends only on ) as
For every and fixed .
If , then .
If ,
If , then .
Recall the property , we know with probability at least over and , it satisfies
Taking expectation over and , we have
This precisely means .
Using the property , we know with probability at least over , it satisfies
Taking expectation also over , we have
In sum, we have just shown that for all choices of ,
and we have with probability at least (and with the remaining probability). Also recalling
Let us state, for completeness’ sake, a simple one-sided Bernstein form of martingale concentration (that we do not know a good reference to it).
Suppose we have a submartingale sequence , satisfying:
Define potential function for some to be chosen later. We have
where the inequality is due to which holds for all . Taking conditional expectation, we have
Choosing the optimal gives us bound