The Curious Case of Adversarially Robust Models: More Data Can Help, Double Descend, or Hurt Generalization
Yifei Min, Lin Chen, Amin Karbasi
Introduction
In recent years, modern machine learning methods have exhibited their superiority over traditional models in an abundance of machine learning tasks, e.g., image classification , speech recognition and language translation , medical diagnosis , text recognition and information extraction , online fraud detection , and self-driving cars , among others. However, they can also be extremely vulnerable to adversarial, human-imperceptible data modifications . This vulnerability is even more concerning and dangerous when machine learning methods are used in scenarios directly connected to human safety such as medical diagnosis (misinterpreting medical images) or self-driving cars (misreading traffic signs). To circumvent these issues, practitioners introduce adversarial training in order to produce adversarially robust models that can still make consistently correct predictions, even when faced with perturbed data.
There is a large body of work dedicated to adversarially robust models . In particular, it has been shown that there exists a trade-off between the generalization of a model (i.e. the standard accuracy) and its robustness to adversarial perturbation . Along a similar vein, Schmidt et al. showed that adversarially robust models need more training data compared to their standard counterparts in order to achieve the same generalization performance. In this paper, we want to further investigate these ideas and explore whether simply adding more data is enough for adversarially robust models to catch up to the generalization ability of their standard counterparts.
Previous works have studied the generalization of adversarially robust models from a variety of perspectives. For instance, Yin et al. and Khim and Loh gave bounds on the generalization error of adversarially robust models via Rademacher complexity. More recently, Chen et al. studied the influence of a larger training set upon the gap between the generalization performance of an adversarially robust model and a standard model. They proved that more training data could result in expansion of the gap and denied the belief that more training data always helps adversarially robust models reach a similar generalization performance to the standard model. Building on these works, our goal is to move past bounds and gaps, and directly characterize how the size of training set affects the accuracy of adversarially robust models on unperturbed test data.
A conventional wisdom in machine learning is that a larger training set will result in better generalization on the test data. We provably establish a surprising, and to some extent even paradoxical, result that more training data can hurt the generalization of adversarially robust models. We first consider a linear classification problem with a linear loss function and identify three regimes of different adversary strengths, i.e., the weak, medium, and strong adversary regimes.
In the strong adversary regime, the generalization of adversarially robust models deteriorates with more training data, except for a possible short initial stage where the generalization is improved with more data.
The medium adversary regime is probably the most interesting one among the three regimes. In this regime, the evolution of the generalization performance of adversarially robust models could be a double descent curve. In particular, at the initial stage, the generalization loss on the test data is reduced with more training data. At the intermediate stage, however, the generalization loss increases as there is more training data (more data hurts the generalization of adversarial robust models). At the final stage, more training data improves the generalization performance.
In the weak adversary regime, the generalization is consistently improved with more training data.
We then move to the analysis of the 0-1 loss and investigate a two-dimensional classification problem where the candidate decision boundary is given by a piecewise constant function. Similar weak and strong adversary regimes are observed under this setting. In particular, in the strong adversary regime, more data always hurts the generalization of adversarially robust models.
We complement the above theroetical results with empirical studies on important machine learning models, including support vector machines (SVMs), linear regression, and Gaussian mixture classification with 0-1 loss. We observe a similar phenomenon that more data hurts generalization in adversarial training. These empirical results suggest that the observed phenomenon may be ubiquitous across different models and loss functions and that we need to reflect on the true role that the size of the training set plays in adversarial training.
Related Work
In this section, we briefly discuss some additional papers on the generalization of adversarially robust models and the double descent phenomenon, which are most relevant to our work.
Schmidt et al. showed that adversarially robust models need more training data compared to their standard counterpart. They considered a Gaussian mixture model similar to ours and proved that the training of a robust model requires a training set with size where is the dimension of the data, whereas the standard model only needs a constant number of data points. Bubeck et al. studied a binary classification problem under a statistical query setting and showed that to train a robust classifier one needs exponentially (in dimension ) many queries, while only polynomially many to train a standard classifier. The main difference between their work and our work is that we quantify the training dynamic in terms of the size of the training set. Very recently, Javanmard et al. precisely characterized the trade-off of standard/robust accuracy under the linear regression setting. Raghunathan et al. gave empirical evidence that adversarial training could hurt the standard accuracy, despite its improvement on robustness. The PAC-learning setting has also been studied by several authors . Cullina et al. provided a polynomial (in the VC dimension) upper bound for the sample complexity, while Diochnos et al. gave a lower bound for the sample complexity which is exponential in the dimension of the input.
The strength of the adversary is crucial in the adversarial training. Theoretically, Dohmatob showed that a classifier with high standard accuracy can inevitably be fooled by a strong adversary. Empirically, Papernot et al. and Tsipras et al. found that a strong adversary can drive down standard accuracy for robust models. Ilyas et al. found that the adversarial training tends to learn non-robust features and omit robust ones if the adversary is too strong.
The double descent phenomenon has been studied by several authors. Belkin et al. and Mei and Montanari provably showed the existence of double descent curves for the generalization error. However, we would like to remark that the double descent curve they considered is in terms of the number of parameters (model complexity), while ours is sample-wise. Empirically, Nakkiran et al. also discovered a sample-wise double descent phenomenon.
Preliminaries
The generalization error of the robust classifier is given by
where the inner expectation is over the randomness of the test data point and the outer expectation is over the randomness of the training dataset. The test and training data are assumed to be independently sampled from the same distribution. The generalization error can be interpreted as the expected loss of the robust model over standard/unperturbed test data.
Theoretical Results
In this section we study two different binary classification models. In Section 4.1, we analyze the Gaussian mixture model under linear loss and prove the existence of three possible regimes (weak, medium and strong adversary regimes), in which more training data can help, double descend, or hurt generalization of the adversarially trained model, respectively. In Section 4.2, we construct a model called the Manhattan model that enables us to analyze the 0-1 loss and prove that analogous weak and strong adversary regimes also exist under a different loss function.
We study how the generalization error of the robust model evolves as the size of the training dataset changes, i.e., the dependence of on . By (2) the generalization error of the robust classifier under linear loss is given by
For the Gaussian classification problem under the linear loss, we identify that the behavior of exhibits a phase transition which is determined by the strength of the adversary. Our main result is summarized by Theorem 1.
Given i.i.d. training data points , if the robust classifier is defined by (3) and its generalization error is defined by (4), then there exist , such that
If , then for all . That is, the loss monotonically decreases as the number of training points increases.
If , and we further assume that is the same for all , then there exist such that
If , then there exists such that for all .
Theorem 1 verifies the existence of three possible regimes during the commonly used adversarial training procedure and gives conditions for when the phase transition between these regimes will take place. Part (a) identifies the weak regime, showing that when the strength of the adversary is small compared to the signal , the generalization error decreases as the size of the training dataset increases. In this regime, the generalization benefits from the use of a large training set. This regime is illustrated by Fig. 1(a), where the curve is always decreasing.
However, as the adversary becomes stronger, we reach the medium regime and things change. Part (b) proves the existence of a double descent curve for the generalization error. It shows that when becomes larger and approaches the signal in magnitude, the generalization error will first decrease as more training data is used. Surprisingly, once it reaches a certain point, it will start increasing as we feed more data. This increasing stage continues until the dataset size reaches some threshold and then the error will decrease again. The medium adversary regime is illustrated by Fig. 1(b), where the three stages are marked by three different colored areas.
If the adversary’s strength reaches the signal level or becomes even stronger, then for all sufficiently large , the generalization error monotonically increases as the size of training set increases. This strong regime is described in part (c) of Theorem 1 and illustrated by Fig. 1(c). Note that despite the decreasing stage near the very beginning, the loss keeps going up after the threshold .
Furthermore, we see that in the medium regime, the length of the increasing stage is given by , according to part (b) of Theorem 1. We would like to remark that the model can have an arbitrarily long increasing stage, which depends on the adversary’s strength. To better interpret this idea and the meaning behind Theorem 1, we consider the following special case where and for all . In this special case, it can be shown that in the medium regime, as approaches the signal strength , the increasing stage grows and can be arbitrarily long.
Under the same assumption as Theorem 1 and further assuming that and for all , we have
If , then for all .
If , then there exist such that
and .
If , then there exists such that for all .
Part (a) and (c) of 2 are a re-statement of corresponding parts of Theorem 1 in the simplified setting. Part (b) additionally states that as increases towards , the length of the increasing stage goes to infinity. In this setting, the three regimes are marked by the thresholds , and .
Fig. 2 illustrates the behavior of the generalization error in this simplified setting. In the simulation we set the parameters as , and (for all three plots). Fig. 2(a) shows the weak adversary regime. We see that the generalization error maintains a decreasing trend when is as large as half the signal strength. In Fig. 2(b), it is clear that the generalization error has a double descent curve. At first there is a decreasing stage, which is followed by an increasing stage. Also observe that as becomes larger, the error increases faster during the increasing stage. The error will finally start decreasing as the size of training dataset reaches the second decreasing stage. On the contrary, in the strong adversary regime, the increasing stage lasts forever and the error keeps increasing no matter how much data is provided, as illustrated by Fig. 2(c).
2 Manhattan Model
In general, the 0-1 loss is mathematically intractable for most data models and computationally prohibitive to optimize in practice. With this in mind, we introduce a conceptual classification model that we call the Manhattan model. Note that this model is highly simplified and thus unlikely to be suitable for modeling real-world problems. Instead, the purpose of the Manhattan model is to allow a mathematical study of the 0-1 loss, and thus provide a springboard for the study of 0-1 loss in more complicated models.
We start by describing the data distribution. Assume we have data points , where the support of is given as : , where . In other words, every data point consists of a positive or negative label and a point on the 2-D plane where is an integer between 1 and and is either or depending on whether the label is or . Thus, the support consists of exactly points with half in the positive class and half in the negative class. The data is uniformly sampled from these points and this distribution is denoted by .
Next, we consider a conceptual classifier of the form of a step function over the 2-D -plane. That is, a classifier is defined by a function such that where
A point is classified if and if . If , then is classified as either or uniformly at random. Fig. 3 illustrates the support of the data distribution, as well as a possible classifier .
where is the Heaviside step function. Note that the RHS of Eq. 6 is the limit of a sequence of sets. This slight abuse of notation is justified by the following Lemma 3, which shows for all sufficiently small , the set remains fixed. We define the set of candidate classifiers without the penalty as
For all sufficiently small and for any , the set defined by Eq. 6 is equivalent to the following set which is nonempty
The generalization error of is then given by
Assume the training data where . For the robust classifier defined by (6) and its generalization error defined by (8), we have
If , then L_{n}=0\ for all .
If , then L_{n+1}>L_{n}\ for all .
Again, the purpose of the Manhattan model is not to model any real-world problems, but instead to show that adversarial training under a 0-1 loss can also be characterized with weak/strong regimes. More generally, we have now shown that the existence of weak/strong regimes is not solely an artifact of the linear loss used in Section 4.1, and thus that it may not be surprising to see analogous results for a much broader class of loss functions.
Empirical Results
In this section, we empirically study the generalization error of robust models in three settings.
We remark that under this setting, the robust classifier is not unique and the set of classifiers is an interval (details in Section D.1). Thus to select a classifier, we consider two tiebreaking methods. One is the agnostic tiebreak, which means the classifier is chosen uniformly at random from the interval. The other is the optimal tiebreak in hindsight, referring to picking the classifier from the interval with the smallest expected test loss. The test loss of a classifier is given by
where is the CDF of the standard normal distribution. In Section D.2, we explain that the optimal classifier in hindsight is the one that is closest to among the interval of classifiers.
Fig. 4(a) and Fig. 4(b) illustrate the test loss versus the size of the training dataset under the agnostic tiebreak and the optimal tiebreak in hindsight. We set and use the same set of values for for both tiebreaking methods. We have three observations. First, the generalization error is increasing in when is larger than the signal strength. This confirms the existence of the strong adversary regime under the 0-1 loss. Second, for small enough (e.g. ), the generalization error is decreasing in (more precisely after ), thus also confirming a weak adversary regime. For the medium adversary where is in between and , the curve has an increasing stage followed by a decreasing stage, which is very similar to what we see in Fig. 2(b).
2 Support Vector Machine
We study the soft-margin support vector machine with hinge loss (details in Appendix E). The dimension equals 2 and the data is generated as and where . The results are shown in Fig. 4(c) and Fig. 4(d). We find that for small the standard test loss keeps decreasing, while for large it keeps increasing. The curves reveal a transition from the weak to the strong regime as grows, and such transition occurs when is in between 0.5 and 0.7. Note that at , the test loss increases even though the strength of the adversary is still weaker than the signal level. This may indicate that for more complicated models (such as SVMs), even relatively weaker adversaries can result in situations where more data always increases the test loss.
3 Linear Regression
Conclusion
The goal of adversarial training is to produce robust models that provide protection against attacks that make perturbations to the data at test time. While protection against such attacks is undoubtedly important, we still want our robust models to perform well on unperturbed data. However, our results indicate that there are scenarios in which it is impossible for current approaches to achieve low generalization error on both datasets simultaneously. This is in direct contradiction to one of the primary tenets of machine learning, which is that more data should help us learn better. Our findings suggest that the current adversarial training framework may not be ideal and that fundamentally new ideas may be required to develop models that can reliably perform well on both perturbed and unperturbed test sets.
Acknowledgements
We would like to thank Peter Bartlett and Yiping Lu for helpful comments and thank Marko Mitrovic for his help in preparation of the paper.
References
Appendix A Proof of Theorem 1 and 2
Before proving Theorem 1, we need to establish several lemmas. First we restate the result by Chen et al. that gives the closed form solution for the robust classifier.
First, we define the error function by
In light of the density of the standard normal distribution and by a change of variable, we have
In addition, we define the function by
where and are defined in the data generation process described at the beginning of Section 4.
Lemma 7 gives the expression for the generalization error.
Suppose that the generalization error is defined as in (4). Then we have
where and are defined in (12).
By (4), 5 and the independence between test and training data, we have
Since , we have , and it follows that
where is a standard normal random variable. By Lemma 6 we have
which implies that .
Note that is differentiable in , and by our definition each is smooth and monotonic in . Together with Lemma 7 we know that is differentiable w.r.t. . Therefore, to study the dynamic of in , it is equivalent to studying the derivative . We define the function by
In Lemma 8, we compute the partial derivative of .
Let and be defined as in (A). The partial derivative of w.r.t. is given by
The proof of Theorem 1 follows from studying the derivative . Lemma 8 implies that the derivative depends on the sign of the function . We investigate the sign of in Lemma 9.
There exist such that the following statements hold.
When , for .
When , there exist depending on such that
When , , there exists such that
We compute the partial derivative of w.r.t.
The proof of Lemma 9 uses the following Lemma 10 and Lemma 11. To make it concise, whenever we fix in the context, we omit and write and .
The right-sided limit of at is given by
The proof of Lemma 10 follows from direct computation. Using Lemma 10, we obtain Lemma 11.
For any fixed , there exists some such that is strictly increasing for and strictly decreasing for . For any fixed , is strictly decreasing for .
We differentiate w.r.t. to get
First we consider the case where . The function is continuously differentiable on . For any fixed , setting yields the unique solution of in as
Since , is strictly increasing w.r.t. . Also note that
which together with indicates that is strictly decreasing for . We conclude that is the unique local extreme and also the global maximum of on .
For , we have for all
It follows that , which implies that is strictly decreasing.
A direct application of Lemma 11 gives the following Lemma 12
For all sufficiently close to 1, has exactly two zeros on .
By Lemma 11, we know that is strictly increasing on and strictly decreasing on . Recall that Lemma 10 shows that for , and . Therefore it suffices to show for all sufficiently close to . We define
We have tends to as . We then write
Note that , and
Therefore we conclude that as .
We denote the two zeros in Lemma 12 by and where .
We show (a) first. Note that for any fixed , . Therefore it suffices to show that for any sufficiently close to , the derivative . Since by Lemma 11 we have when , it remains to show that for all sufficiently close to 0.
In light of (13), is equivalent to
Rearranging the terms yields . Since and , we have . Thus it now suffices to show , or equivalently . We can further simplify this into
Now we show (b). By Lemma 12, we know that for all sufficiently close to , has exactly two zeros and . By Lemma 11, we know that for . These imply that is decreasing on , increasing on and decreasing on , which gives . Furthermore, since and for , we know in . Also note that . Therefore, depending on , the sign of in only has two possibilities: either for all except possibly one point where , or there exist and as described in (b). In the latter case we have .
We now show the existence of such and for all sufficiently close to . Since we have shown that and , it suffices to show . Since , we have , which can be simplified into
Since , it then suffices to show
The claim in (b) that follows directly from the above analysis since and .
To show , we claim that as . Then it suffices to show that for all . We have
which tends to 1 as . This implies (b).
We now show (c). First note that and .
When , . In this case, we have for and for .
When , by Lemma 11, we have being strictly decreasing on . Therefore the function is concave. Since , and , the result follows by concavity.
When , again since and , it suffices to show is strictly increasing and then strictly decreasing on . Note that since and , it then suffices to show is increasing and then decreasing on . To show this, it suffices to show that if for some , then for all . Now, since
and for all , we conclude that for all . So we are done.
Now we are in a position to prove Theorem 1.
Let for all . By Lemma 7 and Lemma 8, we have
By part (a) of Lemma 9, when , we have for all , it holds that and thus for all . Combining it with (15) yields .
When , we have for all , it holds that . It follows from part (c) of Lemma 9 that for all , there exists such that . Pick . Then for all , we have when . Since , when , or equivalently , we have .
When , we have for all , it holds that . Then by part (b) of Lemma 9, for all , and such that
where as and , for all . Let , and . Note that since , without loss of generality we can assume . It follows from (16) that for all
Denote for all since this ratio is fixed. Then we have . Therefore we can choose , , and where and the result follows from (15) and (17).
From the proof of Theorem 1, in this simplified case we have and for all . It follows that the thresholds and in Theorem 1 satisfy , and is no longer needed and can be replaced by . Therefore only two thresholds are needed in 2. We denote the two thresholds as and .
It remains to show . From part (b) of Lemma 9 and (15), we know the derivative is positive when , or equivalently . By (b) of Lemma 9, we know as while is bounded away from . This shows and completes the proof. ∎
Appendix B Proof of Lemma 3
Note that by letting , any two intervals have no overlap. To see why is a constant function over each interval , we consider three possible cases of the dataset . For the first case, suppose that those data points with contain only positive points. Then in order to correctly classify these points with perturbation, we must have for all . In order to minimize , we would take . Similarly, if those points purely consist of negative points, then . For the second case, suppose that those data points with contain both positive and negative points. Suppose the number of positive points exceeds the number of negative points. Then to correctly classify the positive points, we have for all . To correctly classify the negative points, we have for all . If , then . Otherwise, if , then can never simultaneously classify both classes correctly. It will choose to correctly classify the class with more points, which is the positive class. Then . On the other hand, if negative class has more points, then . If the two class have equal number of points at , then can be either or . For the third case, assume no point in the training set has . Then .
We have now specified the form that can take, which also indicates that is nonempty. We now show for all sufficiently small , .
First we show . Let . We want to show and for all . Suppose on the contrary that . Then by definition of , there exists s.t.
and since is nonempty we can further assume satisfies
Since , we then have , which implies . From above analysis we know must take the form of Eq. 18 where , and has length equal to . This implies . Therefore, if we pick , then such cannot exist. Therefore, for all sufficiently small , we have .
Now we show for all . Suppose on the contrary that there exists such that . However, since we have already shown
this would contradict the fact that . Therefore we have .
To see for all sufficiently small , we again pick . Note that since for all , we have . Now suppose on the contrary that there exists such that
which is a contradiction. Therefore . Altogether we have .
Appendix C Proof of Theorem 4
The proof follows from the Lemma 3 and its proof. By Lemma 3, we have and we can consider the equivalent definition that . From the proof of Lemma 3, we know must take the form of (18). Since , when , we have and thus for all . For such , we have for all in the support of . This implies for all .
Assume . Then can take the value of either or . When , can classify both the positive and negative points at location correctly. When , then can only classify one of the two classes correctly. Note that if and only if there is no point with in the training set. Let the random variable denote the cardinality of the set , which is a function of the training set . Then the generalization error can be written as
Note that decreases as increases. Therefore for all .
Appendix D Further Details on Gaussian Mixture with 0-1 Loss
If the training dataset is , we define the neuralized dataset that satisfies for all . In other words, for a positive sample , we obtain its neutralized sample by shifting to the negative direction by , i.e., ; for a negative sample , its neutralized sample is obtained by shifting to the positive direction by , i.e., . We see that the dataset remains unchanged after neutralization if . With this definition, the robust classifier can be expressed as the following.
Given the training dataset and the neuralized dataset , the robust classifier is given by
Now one can see the tiebreaking issue in light of 13. To see this, let be the permutation of such that . The points divide the real line into intervals: , for , and . Let be a minimizer of (19). If lies in any of the above intervals, then any other point in the same interval is also a minimizer, since at these two points the objective function has the same value. Therefore, a tiebreaking procedure is required here.
For the agnostic tiebreak, if , it chooses uniformly at random from the interval. If , it chooses arbitrarily close to from above. If , it chooses .
By (1), it suffices to show that under the 0-1 loss
D.2 Test Loss and Optimal Tiebreak
To find the optimal tiebreaking in hingsight, we need to minimize the test loss over the model parameter , which is given by 14.
The test loss of classifier is given by
where is the CDF of the standard normal distribution. Furthermore, the minimizer of (21) is .
14 indicates that the optimal tiebreak in hindsight chooses the point closest to (i.e., the point with the minimum absolute value) from (the closure of) the interval where lies. This is because minimizes the test loss in (21), and one can see that (21) increases as increases. Indeed, the derivative of (21) is given by , which is negative for and positive for .
Since the derivative is , we see that minimizes the above quantity. ∎
Appendix E Additional Details about the SVM Experiment
The standard test loss (the -axis in Fig. 4(c) and Fig. 4(d)) of the robust classifier is given by
where the penalty term is not included. The robust classifier is solved for by optimizing (22) which is convex in using gradient descent.