Ensemble Adversarial Training: Attacks and Defenses

Florian Tramèr, Alexey Kurakin, Nicolas Papernot, Ian Goodfellow, Dan Boneh, Patrick McDaniel

Introduction

Machine learning (ML) models are often vulnerable to adversarial examples, maliciously perturbed inputs designed to mislead a model at test time (Biggio et al., 2013; Szegedy et al., 2013; Goodfellow et al., 2014b; Papernot et al., 2016a). Furthermore, Szegedy et al. (2013) showed that these inputs transfer across models: the same adversarial example is often misclassified by different models, thus enabling simple black-box attacks on deployed models (Papernot et al., 2017; Liu et al., 2017).

Adversarial training (Szegedy et al., 2013) increases robustness by augmenting training data with adversarial examples. Madry et al. (2017) showed that adversarially trained models can be made robust to white-box attacks (i.e., with knowledge of the model parameters) if the perturbations computed during training closely maximize the model’s loss. However, prior attempts at scaling this approach to ImageNet-scale tasks (Deng et al., 2009) have proven unsuccessful (Kurakin et al., 2017b).

It is thus natural to ask whether it is possible, at scale, to achieve robustness against the class of black-box adversaries Towards this goal, Kurakin et al. (2017b) adversarially trained an Inception v3 model (Szegedy et al., 2016b) on ImageNet using a “single-step” attack based on a linearization of the model’s loss (Goodfellow et al., 2014b). Their trained model is robust to single-step perturbations but remains vulnerable to more costly “multi-step” attacks. Yet, Kurakin et al. (2017b) found that these attacks fail to reliably transfer between models, and thus concluded that the robustness of their model should extend to black-box adversaries. Surprisingly, we show that this is not the case.

We demonstrate, formally and empirically, that adversarial training with single-step methods admits a degenerate global minimum, wherein the model’s loss can not be reliably approximated by a linear function. Specifically, we find that the model’s decision surface exhibits sharp curvature near the data points, thus degrading attacks based on a single gradient computation. In addition to the model of Kurakin et al. (2017b), we reveal similar overfitting in an adversarially trained Inception ResNet v2 model (Szegedy et al., 2016a), and a variety of models trained on MNIST (LeCun et al., 1998).

We harness this result in two ways. First, we show that adversarially trained models using single-step methods remain vulnerable to simple attacks. For black-box adversaries, we find that perturbations crafted on an undefended model often transfer to an adversarially trained one. We also introduce a simple yet powerful single-step attack, which we call R+FGSM, that applies a small random perturbation—to escape the non-smooth vicinity of the data point—before linearizing the model’s loss. While seemingly weaker than the Fast Gradient Sign Method of Goodfellow et al. (2014b), our attack significantly outperforms it for a same perturbation norm, for models trained with or without adversarial training.

Second, we propose Ensemble Adversarial Training, a training methodology that incorporates perturbed inputs transferred from other pre-trained models. Our approach decouples adversarial example generation from the parameters of the trained model, and increases the diversity of perturbations seen during training. We train Inception v3 and Inception ResNet v2 models on ImageNet that exhibit increased robustness to adversarial examples transferred from other holdout models, using various single-step and multi-step attacks (Goodfellow et al., 2014b; Carlini & Wagner, 2017a; Kurakin et al., 2017a; Madry et al., 2017). We also show that our methods globally reduce the dimensionality of the space of adversarial examples (Tramèr et al., 2017). Our Inception ResNet v2 model won the first round of the NIPS 2017 competition on Defenses Against Adversarial Attacks (Kurakin et al., 2017c), where it was evaluated on other competitors’ attacks in a black-box setting.We publicly released our model after the first round, and it could thereafter be targeted using white-box attacks. Nevertheless, a majority of the top submissions in the final round, e.g. (Xie et al., 2018) built upon our released model.

We further note that adversarial training with multi-step attacks has now been scaled to ImageNet (Xie et al., 2019a), resulting in models with plausible and non-negligible robustness to white-box attacks, thereby superseding the results obtained with Ensemble Adversarial Training. Adversarial training with multi-step attacks is currently regarded as the state-of-the-art approach for attaining robustness to a fixed type of perturbations, whether in a white-box or black-box setting.

At the same time, a surprising recent result of Wong et al. (2020) suggests that with appropriate step-size tuning and early-stopping, adversarial training with the single-step R+FGSM attack yields models with white-box robustness that is comparable to that obtained with more expensive multi-step attacks (Madry et al., 2017).

Related Work

Various defensive techniques against adversarial examples in deep neural networks have been proposed (Gu & Rigazio, 2014; Luo et al., 2015; Papernot et al., 2016c; Nayebi & Ganguli, 2017; Cisse et al., 2017) and many remain vulnerable to adaptive attackers (Carlini & Wagner, 2017a; b; Baluja & Fischer, 2017). Adversarial training (Szegedy et al., 2013; Goodfellow et al., 2014b; Kurakin et al., 2017b; Madry et al., 2017) appears to hold the greatest promise for learning robust models.

Madry et al. (2017) show that adversarial training on MNIST yields models that are robust to white-box attacks, if the adversarial examples used in training closely maximize the model’s loss. Moreover, recent works by Sinha et al. (2018), Raghunathan et al. (2018) and Kolter & Wong (2017) even succeed in providing certifiable robustness for small perturbations on MNIST. As we argue in Appendix C, the MNIST dataset is peculiar in that there exists a simple “closed-form” denoising procedure (namely feature binarization) which leads to similarly robust models without adversarial training. This may explain why robustness to white-box attacks is hard to scale to tasks such as ImageNet (Kurakin et al., 2017b). We believe that the existence of a simple robust baseline for MNIST can be useful for understanding some limitations of adversarial training techniques.

Szegedy et al. (2013) found that adversarial examples transfer between models, thus enabling black-box attacks on deployed models. Papernot et al. (2017) showed that black-box attacks could succeed with no access to training data, by exploiting the target model’s predictions to extract (Tramèr et al., 2016) a surrogate model. Some prior works have hinted that adversarially trained models may remain vulnerable to black-box attacks: Goodfellow et al. (2014b) found that an adversarial maxout network on MNIST has slightly higher error on transferred examples than on white-box examples. Papernot et al. (2017) further showed that a model trained on small perturbations can be evaded by transferring perturbations of larger magnitude. Our finding that adversarial training degrades the accuracy of linear approximations of the model’s loss is as an instance of a gradient-masking phenomenon (Papernot et al., 2016b), which affects other defensive techniques (Papernot et al., 2016c; Carlini & Wagner, 2017a; Nayebi & Ganguli, 2017; Brendel & Bethge, 2017; Athalye et al., 2018).

The Adversarial Training Framework

We distinguish between white-box adversaries that have access to the target model’s parameters (i.e., hh), and black-box adversaries with only partial information about the model’s inner workings. Formal definitions for these adversaries are in Appendix A. Although security against white-box attacks is the stronger notion (and the one we ideally want ML models to achieve), black-box security is a reasonable and more tractable goal for deployed ML models.

2 Adversarial Training

Following Madry et al. (2017), we consider an adversarial variant of standard Empirical Risk Minimization (ERM), where our aim is to minimize the risk over adversarial examples:

Madry et al. (2017) argue that adversarial training has a natural interpretation in this context, where a given attack (see below) is used to approximate solutions to the inner maximization problem, and the outer minimization problem corresponds to training over these examples. Note that the original formulation of adversarial training (Szegedy et al., 2013; Goodfellow et al., 2014b), which we use in our experiments, trains on both the “clean” examples xx and adversarial examples xadvx^{\text{adv}}.

Fast Gradient Sign Method (FGSM). This method (Goodfellow et al., 2014b) linearizes the inner maximization problem in (1):

Single-Step Least-Likely Class Method (Step-LL). This variant of FGSM introduced by Kurakin et al. (2017a; b) targets the least-likely class, yLL=arg min⁡{h(x)}y_{\text{LL}}=\operatorname*{arg\,min}\{h(x)\}:

Although this attack only indirectly tackles the inner maximization in (1), Kurakin et al. (2017b) find it to be the most effective for adversarial training on ImageNet.

3 A Degenerate Global Minimum for Single-Step Adversarial Training

When performing adversarial training with a single-step attack (e.g., the FGSM or Step-LL methods above), we approximate Equation (1) by replacing the solution to the inner maximization problem in with the output of the single-step attack (e.g., xFGSMadvx^{\text{adv}}_{\text{FGSM}} in (2)). That is, we solve

For model families H\mathcal{H} with high expressive power, this alternative optimization problem admits at least two substantially different global minima h∗h^{*}:

The minimizer h∗h^{*} is a model for which the approximation method underlying the attack (i.e., linearization in our case) poorly fits the model’s loss function. That is,

Thus the attack when applied to h∗h^{*} produces samples xadvx^{\text{adv}} that are far from optimal.

Note that this second “degenerate” minimum can be more subtle than a simple case of overfitting to samples produced from single-step attacks. Indeed, we show in Section 4.1 that single-step attacks applied to adversarially trained models create “adversarial” examples that are easy to classify even for undefended models. Thus, adversarial training does not simply learn to resist the particular attack used during training, but actually to make that attack perform worse overall. This phenomenon relates to the notion of Reward Hacking (Amodei et al., 2016) wherein an agent maximizes its formal objective function via unintended behavior that fails to captures the designer’s true intent.

4 Ensemble Adversarial Training

The degenerate minimum described in Section 3.3 is attainable because the learned model’s parameters influence the quality of both the minimization and maximization in (1). One solution is to use a stronger adversarial example generation process, at a high performance cost (Madry et al., 2017). Alternatively, Baluja & Fischer (2017) suggest training an adversarial generator model as in the GAN framework (Goodfellow et al., 2014a). The power of this generator is likely to require careful tuning, to avoid similar degenerate minima (where the generator or classifier overpowers the other).

We propose a conceptually simpler approach to decouple the generation of adversarial examples from the model being trained, while simultaneously drawing an explicit connection with robustness to black-box adversaries. Our method, which we call Ensemble Adversarial Training, augments a model’s training data with adversarial examples crafted on other static pre-trained models. Intuitively, as adversarial examples transfer between models, perturbations crafted on an external model are good approximations for the maximization problem in (1). Moreover, the learned model can not influence the “strength” of these adversarial examples. As a result, minimizing the training loss implies increased robustness to black-box attacks from some set of models.

We can draw a connection between Ensemble Adversarial Training and multiple-source Domain Adaptation (Mansour et al., 2009; Zhang et al., 2012). In Domain Adaptation, a model trained on data sampled from one or more source distributions S1,…,Sk\mathcal{S}_{1},\dots,\mathcal{S}_{k} is evaluated on samples xx from a different target distribution T\mathcal{T}.

Let Ai\mathcal{A}_{i} be an adversarial distribution obtained by sampling (x,ytrue)(x,y_{\text{true}}) from D\mathcal{D}, computing an adversarial example xadvx^{\text{adv}} for some model such that ∥xadv−x∥∞≤ϵ\|x^{\text{adv}}-x\|_{\infty}\leq\epsilon, and outputting (xadv,ytrue)(x^{\text{adv}},y_{\text{true}}). In Ensemble Adversarial Training, the source distributions are D\mathcal{D} (the clean data) and A1,…,Ak\mathcal{A}_{1},\dots,\mathcal{A}_{k} (the attacks overs the currently trained model and the static pre-trained models). The target distribution takes the form of an unseen black-box adversary A∗\mathcal{A^{*}}. Standard generalization bounds for Domain Adaptation (Mansour et al., 2009; Zhang et al., 2012) yield the following result.

Let h∗∈Hh^{*}\in\mathcal{H} be a model learned with Ensemble Adversarial Training and static black-box adversaries A1,…,Ak\mathcal{A}_{1},\dots,\mathcal{A}_{k}. Then, if h∗h^{*} is robust against the black-box adversaries A1,…Ak\mathcal{A}_{1},\dots\mathcal{A}_{k} used at training time, then h∗h^{*} has bounded error on attacks from a future black-box adversary A∗\mathcal{A^{*}}, if A∗\mathcal{A^{*}} is not “much stronger”, on average, than the static adversaries A1,…,Ak\mathcal{A}_{1},\dots,\mathcal{A}_{k}.

Experiments

We show the existence of a degenerate minimum, as described in Section 3.3, for the adversarially trained Inception v3 model of Kurakin et al. (2017b). Their model (denoted v3adv{}_{\text{adv}}) was trained on a Step-LL attack with ϵ≤16/256\epsilon\leq{16}/{256}. We also adversarially train an Inception ResNet v2 model (Szegedy et al., 2016a) using the same setup. We denote this model by IRv2adv{}_{\text{adv}}. We refer the reader to (Kurakin et al., 2017b) for details on the adversarial training procedure.

We first measure the approximation-ratio of the Step-LL attack for the inner maximization in (1). As we do not know the true maximum, we lower-bound it using an iterative attack. For 1,0001{,}000 random test points, we find that for a standard Inception v3 model, step-LL gets within 19%19\% of the optimum loss on average. This attack is thus a good candidate for adversarial training. Yet, for the v3adv{}_{\text{adv}} model, the approximation ratio drops to 7%7\%, confirming that the learned model is less amenable to linearization. We obtain similar results for Inception ResNet v2 models. The ratio is 17%17\% for a standard model, and 8%8\% for IRv2adv{}_{\text{adv}}. Similarly, we look at the cosine similarity between the perturbations given by a single-step and multi-step attack. The more linear the model, the more similar we expect both perturbations to be. The average similarity drops from 0.130.13 for Inception v3 to 0.020.02 for v3adv{}_{\text{adv}}. This effect is not due to the decision surface of v3adv{}_{\text{adv}} being “too flat” near the data points: the average gradient norm is larger for v3adv{}_{\text{adv}} (0.170.17) than for the standard v3 model (0.100.10).

We show similar results for adversarially trained MNIST models in Appendix C.2. On this task, input dropout (Srivastava et al., 2014) mitigates adversarial training’s overfitting problem, in some cases. Presumably, the random input mask diversifies the perturbations seen during training (dropout at intermediate layers does not mitigate the overfitting effect). Mishkin et al. (2017) find that input dropout significantly degrades accuracy on ImageNet, so we did not include it in our experiments.

Kurakin et al. (2017b) found their adversarially trained model to be robust to various single-step attacks. They conclude that this robustness should translate to attacks transferred from other models. As we have shown, the robustness to single-step attacks is actually misleading, as the model has learned to degrade the information contained in the model’s gradient. As a consequence, we find that the v3adv{}_{\text{adv}} model is substantially more vulnerable to single-step attacks than Kurakin et al. (2017b) predicted, both in a white-box and black-box setting. The same holds for the IRv2adv{}_{\text{adv}} model.

In addition to the v3adv{}_{\text{adv}} and IRv2adv{}_{\text{adv}} models, we consider standard Inception v3, Inception v4 and Inception ResNet v2 models. These models are available in the TensorFlow-Slim library (Abadi et al., 2015). We describe similar results for a variety of models trained on MNIST in Appendix C.2.

Table 1 shows error rates for single-step attacks transferred between models. We compute perturbations on one model (the source) and transfer them to all others (the targets). When the source and target are the same, the attack is white-box. Adversarial training greatly increases robustness to white-box single-step attacks, but incurs a higher error rate in a black-box setting. Thus, the robustness gain observed when evaluating defended models in isolation is misleading. Given the ubiquity of this pitfall among proposed defenses against adversarial examples (Carlini & Wagner, 2017a; Brendel & Bethge, 2017; Papernot et al., 2016b), we advise researchers to always consider both white-box and black-box adversaries when evaluating defensive strategies. Notably, a similar discrepancy between white-box and black-box attacks was recently observed in Buckman et al. (2018).

Attacks crafted on adversarial models are found to be weaker even against undefended models (i.e., when using v3adv{}_{\text{adv}} or IRv2adv{}_{\text{adv}} as source, the attack transfers with lower probability). This confirms our intuition from Section 3.3: adversarial training does not just overfit to perturbations that affect standard models, but actively degrades the linear approximation underlying the single-step attack.

A new randomized single-step attack.

The loss function visualization in Figure 1 shows that sharp curvature artifacts localized near the data points can mask the true direction of steepest ascent. We thus suggest to prepend single-step attacks by a small random step, in order to “escape” the non-smooth vicinity of the data point before linearizing the model’s loss. Our new attack, called R+FGSM (alternatively, R+Step-LL), is defined as follows, for parameters ϵ\epsilon and α\alpha (where α<ϵ\alpha<\epsilon):

Note that the attack requires a single gradient computation. The R+FGSM is a computationally efficient alternative to iterative methods that have high success rates in a white-box setting. Our attack can be seen as a single-step variant of the general PGD method from (Madry et al., 2017).

Table 2 compares error rates for the Step-LL and R+Step-LL methods (with ϵ=16/256\epsilon={16}/{256} and α=ϵ/2\alpha={\epsilon}/{2}). The extra random step yields a stronger attack for all models, even those without adversarial training. This suggests that a model’s loss function is generally less smooth near the data points. We further compared the R+Step-LL attack to a two-step Iter-LL attack, which computes two gradient steps. Surprisingly, we find that for the adversarially trained Inception v3 model, the R+Step-LL attack is stronger than the two-step Iter-LL attack. That is, the local gradients learned by the adversarially trained model are worse than random directions for finding adversarial examples!

We find that the addition of this random step hinders transferability (see Table 9). We also tried adversarial training using R+FGSM on MNIST, using a similar approach as (Madry et al., 2017). We adversarially train a CNN (model A in Table 5) for 100100 epochs, and attain >90.0%>90.0\% accuracy on R+FGSM samples. However, training on R+FGSM provides only little robustness to iterative attacks. For the PGD attack of (Madry et al., 2017) with 2020 steps, the model attains 18.0%18.0\% accuracy. Subsequent work by Wong et al. Wong et al. (2020) shows that single-step adversarial training with an attack similar to R+FGSM successfully yields models robust to white-box attacks, if the step-sizes of the attack’s random and gradient step are appropriately tuned.

2 Ensemble Adversarial Training

We now evaluate our Ensemble Adversarial Training strategy described in Section 3.4. We recall our intuition: by augmenting training data with adversarial examples crafted from static pre-trained models, we decouple the generation of adversarial examples from the model being trained, so as to avoid the degenerate minimum described in Section 3.3. Moreover, our hope is that robustness to attacks transferred from some fixed set of models will generalize to other black-box adversaries.

We train Inception v3 and Inception ResNet v2 models (Szegedy et al., 2016a) on ImageNet, using the pre-trained models shown in Table 3. In each training batch, we rotate the source of adversarial examples between the currently trained model and one of the pre-trained models. We select the source model at random in each batch, to diversify examples across epochs. The pre-trained models’ gradients can be precomputed for the full training set. The per-batch cost of Ensemble Adversarial Training is thus lower than that of standard adversarial training: using our method with n−1n-1 pre-trained models, only every nthn^{\text{th}} batch requires a forward-backward pass to compute adversarial gradients. We use synchronous distributed training on 50 machines, with minibatches of size 16 (we did not pre-compute gradients, and thus lower the batch size to fit all models in memory). Half of the examples in a minibatch are replaced by Step-LL examples. As in Kurakin et al. (2017b), we use RMSProp with a learning rate of 0.0450.045, decayed by a factor of 0.940.94 every two epochs.

To evaluate how robustness to black-box attacks generalizes across models, we transfer various attacks crafted on three different holdout models (see Table 3), as well as on an ensemble of these models (as in Liu et al. (2017)). We use the Step-LL, R+Step-LL, FGSM, I-FGSM and the PGD attack from Madry et al. (2017) using the hinge-loss function from Carlini & Wagner (2017a). Our results are in Table 4. For each model, we report the worst-case error rate over all black-box attacks transfered from each of the holdout models (2020 attacks in total). Results for MNIST are in Table 8.

Convergence of Ensemble Adversarial Training is slower than for standard adversarial training, a result of training on “hard” adversarial examples and lowering the batch size. Kurakin et al. (2017b) report that after 187187 epochs (150k150k iterations with minibatches of size 3232), the v3adv{}_{\text{adv}} model achieves 78%78\% accuracy. Ensemble Adversarial Training for models v3adv-ens3{}_{\text{adv-ens3}} and v3adv-ens4{}_{\text{adv-ens4}} converges after 280280 epochs (450k450k iterations with minibatches of size 1616). The Inception ResNet v2 model is trained for 175175 epochs, where a baseline model converges at around 160160 epochs.

White-box attacks.

For both architectures, the models trained with Ensemble Adversarial Training are slightly less accurate on clean data, compared to standard adversarial training. Our models are also more vulnerable to white-box single-step attacks, as they were only partially trained on such perturbations. Note that for v3adv-ens4{}_{\text{adv-ens4}}, the proportion of white-box Step-LL samples seen during training is \nicefrac14\nicefrac{{1}}{{4}} (instead of \nicefrac13\nicefrac{{1}}{{3}} for model v3adv-ens3{}_{\text{adv-ens3}}). The negative impact on the robustness to white-box attacks is large, for only a minor gain in robustness to transferred samples. Thus it appears that while increasing the diversity of adversarial examples seen during training can provide some marginal improvement, the main benefit of Ensemble Adversarial Training is in decoupling the attacks from the model being trained, which was the goal we stated in Section 3.4.

Ensemble Adversarial Training is not robust to white-box Iter-LL and R+Step-LL samples: the error rates are similar to those for the v3adv{}_{\text{adv}} model, and omitted for brevity (see Kurakin et al. (2017b) for Iter-LL attacks and Table 2 for R+Step-LL attacks). Kurakin et al. (2017b) conjecture that larger models are needed to attain robustness to such attacks. Yet, against black-box adversaries, these attacks are only a concern insofar as they reliably transfer between models.

Black-box attacks.

Ensemble Adversarial Training significantly boosts robustness to the attacks we transfer from the holdout models. For the IRv2adv-ens{}_{\text{adv-ens}} model, the accuracy loss (compared to IRv2’s accuracy on clean data) is 7.4%\mathbf{7.4\%} (top 1) and 3.1%\mathbf{3.1\%} (top 5). We find that the strongest attacks in our test suite (i.e., with highest transfer rates) are the FGSM attacks. Black-box R+Step-LL or iterative attacks are less effective, as they do not transfer with high probability (see Kurakin et al. (2017b) and Table 9). Attacking an ensemble of all three holdout models, as in Liu et al. (2017), did not lead to stronger black-box attacks than when attacking the holdout models individually.

Our results have little variance with respect to the attack parameters (e.g., smaller ϵ\epsilon) or to the use of other holdout models for black-box attacks (e.g., we obtain similar results by attacking the v3adv-ens3{}_{\text{adv-ens3}} and v3adv-ens4{}_{\text{adv-ens4}} models with the IRv2 model). We also find that v3adv-ens3{}_{\text{adv-ens3}} is not vulnerable to perturbations transferred from v3adv-ens4{}_{\text{adv-ens4}}. We obtain similar results on MNIST (see Appendix C.2), thus demonstrating the applicability of our approach to different datasets and model architectures.

Yet, subsequent work (Dong et al., 2019; Xie et al., 2019b; Wu et al., 2020) has proposed new attacks that substantially improve the transferability of adversarial examples. Although Ensemble Adversarial Training still improves a model’s robustness against these attacks, the achieved robust accuracy is greatly reduced. To our knowledge, the strongest attack to date is that proposed by Wu et al. (2020), which reduces the accuracy of the IRv2adv-ens{}_{\text{adv-ens}} to 22%22\%.

The NIPS 2017 competition on adversarial examples.

Our IRv2adv-ens{}_{\text{adv-ens}} model finished 1st among 7070 submissions in the first development round, with a score of 95.3%95.3\% (the second placed defense scored 89.9%89.9\%). The test data was intentionally chosen as an “easy” subset of ImageNet. Our model achieved 97.9%97.9\% accuracy on the clean test data.

After the first round, we released our model publicly, which enabled other users to launch white-box attacks against it. Nevertheless, a majority of the final submissions built upon our released model. The winning submission (team “liaofz” with a score of 95.3%95.3\%) made use of a novel adversarial denoising technique. The second placed defense (team “cihangxie” with a score of 92.4%92.4\%) prepends our IRv2adv-ens{}_{\text{adv-ens}} model with random padding and resizing of the input image (Xie et al., 2018).

It is noteworthy that the defenses that incorporated Ensemble Adversarial Training fared better against the worst-case black-box adversary. Indeed, although very robust on average, the winning defense achieved as low as 11.8%11.8\% accuracy on some attacks. The best defense under this metric (team “rafaelmm” which randomly perturbed images before feeding them to our IRv2adv-ens{}_{\text{adv-ens}} model) achieved at least 53.6%53.6\% accuracy against all submitted attacks, including the attacks that explicitly targeted our released model in a white-box setting.

Decreasing gradient masking.

Ensemble Adversarial Training decreases the magnitude of the gradient masking effect described previously. For the v3adv-ens3{}_{\text{adv-ens3}} and v3adv-ens4{}_{\text{adv-ens4}} models, we find that the loss incurred on a Step-LL attack gets within respectively 13%13\% and 18%18\% of the optimum loss (we recall that for models v3 and v3adv{}_{\text{adv}}, the approximation ratio was respectively 19%19\% and 7%7\%). Similarly, for the IRv2adv-ens{}_{\text{adv-ens}} model, the ratio improves from 8%8\% (for IRv2adv{}_{\text{adv}}) to 14%14\%. As expected, not solely training on a white-box single-step attack reduces gradient masking. We also verify that after Ensemble Adversarial Training, a two-step iterative attack outperforms the R+Step-LL attack from Section 4.1, thus providing further evidence that these models have meaningful gradients.

For models v3, v3adv{}_{\text{adv}} and v3adv-ens3{}_{\text{adv-ens3}}, we select 500500 correctly classified test points. For each xx, we search for a maximal number of orthogonal adversarial perturbations rir_{i} with ∥ri∥∞=ϵ\|r_{i}\|_{\infty}=\epsilon. We limit our search to k≤100k\leq 100 directions per point. The results are in Figure 2. For ϵ∈{4,10,16}\epsilon\in\{4,10,16\}, we plot the proportion of points that have at least kk orthogonal adversarial perturbations. For a fixed ϵ\epsilon, the value of kk can be interpreted as the dimension of a “slice” of the cone of adversarial examples near a data point. For the standard Inception v3 model, we find over 5050 orthogonal adversarial directions for 30%30\% of the points. The v3adv{}_{\text{adv}} model shows a curious bimodal phenomenon for ϵ≥10\epsilon\geq 10: for most points (≈80%\approx 80\%), we find no adversarial direction aligned with the gradient, which is consistent with the gradient masking effect. Yet, for most of the remaining points, the adversarial space is very high-dimensional (k≥90k\geq 90). Ensemble Adversarial Training yields a more robust model, with only a small fraction of points near a large adversarial space.

Conclusion and Future Work

Previous work on adversarial training at scale has produced encouraging results, showing strong robustness to (single-step) adversarial examples (Goodfellow et al., 2014b; Kurakin et al., 2017b). Yet, these results are misleading, as the adversarially trained models remain vulnerable to simple black-box and white-box attacks. Our results, generic with respect to the application domain, suggest that adversarial training can be improved by decoupling the generation of adversarial examples from the model being trained. Our experiments with Ensemble Adversarial Training show that the robustness attained to attacks from some models transfers to attacks from other models.

We did not consider black-box adversaries that attack a model via other means than by transferring examples from a local model. For instance, generative techniques (Baluja & Fischer, 2017) might provide an avenue for stronger attacks. Yet, a recent work by Xiao et al. (2018) found Ensemble Adversarial Training to be resilient to such attacks on MNIST and CIFAR10, and often attaining higher robustness than models that were adversarially trained on iterative attacks.

Moreover, interactive adversaries (see Appendix A) could try to exploit queries to the target model’s prediction function in their attack, as demonstrated in Papernot et al. (2017). If queries to the target model yield prediction confidences, an adversary can estimate the target’s gradient at a given point (e.g., using finite-differences as in Chen et al. (2017)) and fool the target with our R+FGSM attack. Note that if queries only return the predicted label, the attack does not apply. Exploring the impact of these classes of black-box attacks and evaluating their scalability to complex tasks is an interesting avenue for future work.

Acknowledgments

We thank Ben Poole and Jacob Steinhardt for feedback on early versions of this work. Nicolas Papernot is supported by a Google PhD Fellowship in Security. Research was supported in part by the Army Research Laboratory, under Cooperative Agreement Number W911NF-13-2-0045 (ARL Cyber Security CRA), and the Army Research Office under grant W911NF-13-1-0421. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Army Research Laboratory or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for government purposes notwithstanding any copyright notation hereon.

References

Appendix A Threat Model: Formal Definitions

We provide formal definitions for the threat model introduced in Section 3.1. In the following, we explicitly identify the hypothesis space H\mathcal{H} that a model belongs to as describing the model’s architecture. We consider a target model h∈Hh\in\mathcal{H} trained over inputs (x,ytrue)(x,y_{\text{true}}) sampled from a data distribution D\mathcal{D}. More precisely, we write

where train is a randomized training procedure that takes in a description of the model architecture H\mathcal{H}, a training set Xtrain,YtrainX_{\text{train}},Y_{\text{train}} sampled from D\mathcal{D}, and randomness rr.

Given a set of test inputs X,Y={(x1,y1),…,(xm,ym)}X,Y=\{(x_{1},y_{1}),\dots,(x_{m},y_{m})\} from D\mathcal{D} and a budget ϵ>0\epsilon>0, an adversary A\mathcal{A} produces adversarial examples Xadv={x1adv,…,xmadv}X^{\text{adv}}=\{x^{\text{adv}}_{1},\dots,x^{\text{adv}}_{m}\}, such that ∥xi−xiadv∥∞≤ϵ\|x_{i}-x^{\text{adv}}_{i}\|_{\infty}\leq\epsilon for all i∈[1,m]i\in[1,m]. We evaluate success of the attack as the error rate of the target model over XadvX^{\text{adv}}:

We assume A\mathcal{A} can sample inputs according to the data distribution D\mathcal{D}. We define three adversaries.

For a target model h∈Hh\in\mathcal{H}, a white-box adversary is given access to all elements of the training procedure, that is train (the training algorithm), H\mathcal{H} (the model architecture), the training data Xtrain,YtrainX_{\text{train}},Y_{\text{train}}, the randomness rr and the parameters hh. The adversary can use any attack (e.g., those in Section 3.2) to find adversarial inputs.

White-box access to the internal model weights corresponds to a very strong adversarial model. We thus also consider the following relaxed and arguably more realistic notion of a black-box adversary.

For a target model h∈Hh\in\mathcal{H}, a non-interactive black-box adversary only gets access to train (the target model’s training procedure) and H\mathcal{H} (the model architecture). The adversary can sample from the data distribution D\mathcal{D}, and uses a local algorithm to craft adversarial examples XadvX^{\text{adv}}.

Attacks based on transferability (Szegedy et al., 2013) fall in this category, wherein the adversary selects a procedure train′\texttt{train}^{\prime} and model architecture H′\mathcal{H}^{\prime}, trains a local model h′h^{\prime} over D\mathcal{D}, and computes adversarial examples on its local model h′h^{\prime} using white-box attack strategies.

Most importantly, a black-box adversary does not learn the randomness rr used to train the target, nor the target’s parameters hh. The black-box adversaries in our paper are actually slightly stronger than the ones defined above, in that they use the same training data Xtrain,YtrainX_{\text{train}},Y_{\text{train}} as the target model.

We provide A\mathcal{A} with the target’s training procedure train to capture knowledge of defensive strategies applied at training time, e.g., adversarial training (Szegedy et al., 2013; Goodfellow et al., 2014b) or ensemble adversarial training (see Section 4.2). For ensemble adversarial training, A\mathcal{A} also knows the architectures of all pre-trained models. In this work, we always mount black-box attacks that train a local model with a different architecture than the target model. We actually find that black-box attacks on adversarially trained models are stronger in this case (see Table 1).

The main focus of our paper is on non-interactive black-box adversaries as defined above. For completeness, we also formalize a stronger notion of interactive black-box adversaries that additionally issue prediction queries to the target model (Papernot et al., 2017). We note that in cases where ML models are deployed as part of a larger system (e.g., a self driving car), an adversary may not have direct access to the model’s query interface.

For a target model h∈Hh\in\mathcal{H}, an interactive black-box adversary only gets access to train (the target model’s training procedure) and H\mathcal{H} (the model architecture). The adversary issues (adaptive) oracle queries to the target model. That is, for arbitrary inputs x∈dx\in^{d}, the adversary obtains y=arg max⁡h(x)y=\operatorname*{arg\,max}h(x) and uses a local algorithm to craft adversarial examples (given knowledge of H\mathcal{H}, train, and tuples (x,y)(x,y)).

Papernot et al. (2017) show that such attacks are possible even if the adversary only gets access to a small number of samples from D\mathcal{D}. Note that if the target model’s prediction interface additionally returns class scores h(x)h(x), interactive black-box adversaries could use queries to the target model to estimate the model’s gradient (e.g., using finite differences) (Chen et al., 2017), and then apply the attacks in Section 3.2. We further discuss interactive black-box attack strategies in Section 5.

Appendix B Generalization Bound for ensemble Adversarial Training

We provide a formal statement of Theorem 1 in Section 3.4, regarding the generalization guarantees of Ensemble Adversarial Training. For simplicity, we assume that the model is trained solely on adversarial examples computed on the pre-trained models (i.e., we ignore the clean training data and the adversarial examples computed on the model being trained). Our results are easily extended to also consider these data points.

Let D\mathcal{D} be the data distribution and A1,…,Ak,A∗\mathcal{A}_{1},\dots,\mathcal{A}_{k},\mathcal{A}^{*} be adversarial distributions where a sample (x,y)(x,y) is obtained by sampling (x,ytrue)(x,y_{\text{true}}) from D\mathcal{D}, computing an xadvx^{\text{adv}} such that ∥xadv−x∥∞≤ϵ\|x^{\text{adv}}-x\|_{\infty}\leq\epsilon and returning (xadv,ytrue)(x^{\text{adv}},y_{\text{true}}). We assume the model is trained on NN data points ZtrainZ_{\text{train}}, where Nk\frac{N}{k} data points are sampled from each distribution Ai\mathcal{A}_{i}, for 1≤i≤k1\leq i\leq k. We denote Atrain={A1,…,Ak}\mathcal{A}_{\text{train}}=\{\mathcal{A}_{1},\dots,\mathcal{A}_{k}\}. At test time, the model is evaluated on adversarial examples from A∗\mathcal{A}^{*}.

For a model h∈Hh\in\mathcal{H} we define the empirical risk

and the risk over the target distribution (or future adversary)

We further define the average discrepancy distance (Mansour et al., 2009) between distributions Ai\mathcal{A}_{i} and A∗\mathcal{A}^{*} with respect to a hypothesis space H\mathcal{H} as

This quantity characterizes how “different” the future adversary is from the train-time adversaries. Intuitively, the distance disc(Atrain,A∗)\text{disc}(\mathcal{A}_{\text{train}},\mathcal{A}^{*}) is small if the difference in robustness between two models to the target attack A∗\mathcal{A}^{*} is somewhat similar to the difference in robustness between these two models to the attacks used for training (e.g., if the static black-box attacks Ai\mathcal{A}_{i} induce much higher error on some model h1h_{1} than on another model h2h_{2}, then the same should hold for the target attack A∗\mathcal{A}^{*}). In other words, the ranking of the robustness of models h∈Hh\in\mathcal{H} should be similar for the attacks in Atrain\mathcal{A}_{\text{train}} as for A∗\mathcal{A}^{*}.

Finally, let RN(H)R_{N}(\mathcal{H}) be the average Rademacher complexity of the distributions A1,…,Ak\mathcal{A}_{1},\dots,\mathcal{A}_{k} (Zhang et al., 2012). Note that RN(H)→0R_{N}(\mathcal{H})\rightarrow 0 as N→∞N\rightarrow\infty. The following theorem is a corollary of Zhang et al. (2012, Theorem 5.2):

Assume that H\mathcal{H} is a function class consisting of bounded functions. Then, with probability at least 1−ϵ1-\epsilon,

Appendix C Experiments on MNIST

The existence of such a simple robust representation begs the question of why learning a robust model with adversarial training takes so much effort. Finding techniques to improve the performance of adversarial training, even on simple tasks, could provide useful insights for more complex tasks such as ImageNet, where we do not know of a similarly simple “denoising” procedure.

C.2 Results

We repeat experiments from Section 4 on MNIST. We use the architectures in Table 5. We train a standard model for 66 epochs, and an adversarial model with the FGSM (ϵ=0.3\epsilon=0.3) for 12 epochs.

During adversarial training, we avoid the label leaking effect described by Kurakin et al. (2017b) by using the model’s predicted class arg max⁡h(x)\operatorname*{arg\,max}h(x) instead of the true label ytruey_{\text{true}} in the FGSM,

We first analyze the “degenerate” minimum of adversarial training, described in Section 3.3. For each trained model, we compute the approximation-ratio of the FGSM for the inner maximization problem in equation (1). That is, we compare the loss produced by the FGSM with the loss of a strong iterative attack. The results appear in Table 6. As we can see, for all model architectures, adversarial training degraded the quality of a linear approximation to the model’s loss.

We find that input dropout (Srivastava et al., 2014) (i.e., randomly dropping a fraction of input features during training) as used in architecture B limits this unwarranted effect of adversarial training.We thank Arjun Bhagoji, Bo Li and Dawn Song for this observation. If we omit the input dropout (we call this architecture B∗) the single-step attack degrades significantly. We discuss this effect in more detail below. For the fully connected architecture D, we find that the learned model is very close to linear and thus also less prone to the degenerate solution to the min-max problem, as we postulated in Section 3.3.

Table 7 compares error rates of undefended and adversarially trained models on white-box and black-box attacks, as in Section 4.1. Again, model B presents an anomaly. For all other models, we corroborate our findings on ImageNet for adversarial training: (1) black-box attacks trump white-box single-step attacks; (2) white-box single-step attacks are significantly stronger if prepended by a random step. For model Badv{}_{\text{adv}}, the opposite holds true. We believe this is because input dropout increases diversity of attack samples similarly to Ensemble Adversarial Training.

While training with input dropout helps avoid the degradation of the single-step attack, it also significantly delays convergence of the model. Indeed, model Badv{}_{\text{adv}} retains relatively high error on white-box FGSM examples. Adversarial training with input dropout can be seen as comparable to training with a randomized single-step attack, as discussed in Section 4.1.

The positive effect of input dropout is architecture and dataset specific: Adding an input dropout layer to models A, C and D confers only marginal benefit, and is outperformed by Ensemble Adversarial Training, discussed below. Moreover, Mishkin et al. (2017) find that input dropout significantly degrades accuracy on ImageNet. We thus did not incorporate it into our models on ImageNet.

Ensemble Adversarial Training.

To evaluate Ensemble Adversarial Training 3.4, we train two models per architecture. The first, denoted [A-D]adv-ens{}_{\text{adv-ens}}, uses a single pre-trained model of the same type (i.e., Aadv-ens{}_{\text{adv-ens}} is trained on perturbations from another model A). The second model, denoted [A-D]adv-ens3{}_{\text{adv-ens3}}, uses 33 pre-trained models ({A,C,D}\{A,C,D\} or {B,C,D}\{B,C,D\}). We train all models for 1212 epochs.

We evaluate our models on black-box attacks crafted on models A,B,C,D (for a fair comparison, we do not use the same pre-trained models for evaluation, but retrain them with different random seeds). The attacks we consider are the FGSM, I-FGSM and the PGD attack from Madry et al. (2017) with the loss function from Carlini & Wagner (2017a)), all with ϵ=0.3\epsilon=0.3. The results appear in Table 8. For each model, we report the worst-case and average-case error rate over all black-box attacks.

Ensemble Adversarial Training significantly increases robustness to black-box attacks, except for architecture B, which we previously found to not suffer from the same overfitting phenomenon that affects the other adversarially trained networks. Nevertheless, model Badv-ens{}_{\text{adv-ens}} achieves slightly better robustness to white-box and black-box attacks than Badv{}_{\text{adv}}. In the majority of cases, we find that using a single pre-trained model produces good results, but that the extra diversity of including three pre-trained models can sometimes increase robustness even further. Our experiments confirm our conjecture that robustness to black-box attacks generalizes across models. Indeed, we find that when training with three external models, we attain very good robustness against attacks initiated from models with the same architecture (as evidenced by the average error on our attack suite), but also increased robustness to attacks initiated from the fourth holdout model

Appendix D Transferability of Randomized Single-Step Perturbations.

In Section 4.1, we introduced the R+Step-LL attack, an extension of the Step-LL method that prepends the attack with a small random perturbation. In Table 9, we evaluate the transferability of R+Step-LL adversarial examples on ImageNet. We find that the randomized variant produces perturbations that transfer at a much lower rate (see Table 1 for the deterministic variant).

Let v∈{−1,1}dv\in\{-1,1\}^{d} and α∈(0,1)\alpha\in(0,1). Suppose there are k orthogonal vectors r1,…rn∈{−1,1}dr_{1},\dots r_{n}\in\{-1,1\}^{d} satisfying v⊤ri≥α⋅dv^{\top}r_{i}\geq\alpha\cdot d. Then α≤k−12\alpha\leq k^{-\frac{1}{2}}.

Let ri^=ri∥ri∥2=rid\hat{r_{i}}=\frac{r_{i}}{\|r_{i}\|_{2}}=\frac{r_{i}}{\sqrt{d}}. Then, we have

from which we obtain α≤k−12\alpha\leq k^{-\frac{1}{2}}. ∎

This result bounds the number of orthogonal perturbations we can expect to find, for a given alignment with the signed gradient. As a warm-up consider the following trivial construction of kk orthogonal vectors in {−1,1}d\{-1,1\}^{d} that are “somewhat” aligned with sign(g)\texttt{sign}(g). We split sign(g)\texttt{sign}(g) into kk “chunks” of size dk\frac{d}{k} and define rir_{i} to be the vector that is equal to sign(g)\texttt{sign}(g) in the iith chunk and zero otherwise. We obtain sign(g)⊤ri=dk\texttt{sign}(g)^{\top}r_{i}=\frac{d}{k}, a factor k\sqrt{k} worse than the the bound in Lemma 6.

We now provide a construction that meets this upper bound. We make use of Regular Hadamard Matrices of order kk (Colbourn, 2010). These are square matrices HkH_{k} such that: (1) all entries of HkH_{k} are in {−1,1}k\{-1,1\}^{k}; (2) the rows of HkH_{k} are mutually orthogonal; (3) All row sums are equal to k\sqrt{k}.

The order of a Regular Hadamard Matrix is of the form 4u24u^{2} for an integer uu. We use known constructions for k∈{4,16,36,64,100}k\in\{4,16,36,64,100\}.

We construct kk orthogonal vectors r1,…,rk∈{−1,1}dr_{1},\dots,r_{k}\in\{-1,1\}^{d}, where rir_{i} is obtained by repeating the ith row of HkH_{k} \nicefracdk\nicefrac{{d}}{{k}} times (for simplicity, we assume that kk divides dd. Otherwise we pad rir_{i} with zeros). We then multiply each rir_{i} component-wise with sign(g)\texttt{sign}(g). By construction, the kk vectors ri∈{−1,1}dr_{i}\in\{-1,1\}^{d} are mutually orthogonal, and we have sign(g)⊤ri=dk⋅k=d⋅k−\nicefrac12\texttt{sign}(g)^{\top}r_{i}=\frac{d}{k}\cdot\sqrt{k}=d\cdot k^{-\nicefrac{{1}}{{2}}}, which is tight according to Lemma 6.

As the weight of the gradient gg may not be uniformly distributed among its dd components, we apply our construction to a random permutation of the signed gradient. We then obtain

It can be shown that the bound in Lemma 7 can be attained if and only if the rir_{i} are constructed from the rows of a Regular Hadamard Matrix (Colbourn, 2010). For general integers kk for which no such matrix exists, other combinatorial designs may be useful for achieving looser bounds.

Appendix F Illustrations of Gradient Masking in Adversarial Training

In Section 3.3, we show that adversarial training introduces spurious curvature artifacts in the model’s loss function around data points. As a result, one-shot attack strategies based on first-order approximations of the model loss produce perturbations that are non-adversarial. In Figures 4 and 5 we show further illustrations of this phenomenon for the Inception v3adv{}_{\text{adv}} model trained on ImageNet by Kurakin et al. (2017b) as well as for the model Aadv{}_{\text{adv}} we trained on MNIST.