TL;DR
A neural network can be fooled by an input changed by an amount too small for a person to notice. Earlier defences often lacked a clear guarantee, because nobody could be sure the attack used to test them was the strongest. This paper frames robustness as a min-max problem: the model is trained to do well on the worst allowed change to each input. The worst change is found with projected gradient descent (PGD), a multi-step attack. Training on PGD examples gives networks that resist a wide range of attacks. On MNIST the authors report more than 89 percent accuracy against the strongest attack in their test suite, and 46 percent on CIFAR-10.
Builds on: Adversarial Training, Fast Gradient Sign Method, Constrained Optimization · Leads to: Adversarial Training (the PGD form that became the standard baseline)
Why it mattered
The paper names security-critical uses of classifiers, including vision for autonomous cars, face recognition and malware detection, and any of them faces the threat it describes. The paper's central hope, that a model robust to PGD is also robust to other gradient-based attacks, is stated as a conjecture and tested in its experiments. Its framing also changes how an attack is seen: an attack is a strong optimisation problem to be solved well, not a single recipe to be tried once.
Adversarial training before this paper
The idea of training on adversarial inputs predates this paper. The paper's related-work section says adversarial training was introduced with the fast gradient sign method, which is a one-step attack. That attack is weak against iterative adversaries, so networks trained on it were still vulnerable to multi-step attacks.
The problem
Write for the model parameters, for the loss on input with label , and for the set of allowed changes. Standard training minimises the average loss on clean inputs. The paper asks for a classifier whose loss stays small on every allowed change of every input, so it proposes the saddle point problem (the paper's equation 2.1). Its two parts are hard for different reasons.
The inner maximisation is non-concave. Finding the worst allowed change for one input is maximising a function that has many local maxima, so it could look intractable. Earlier work avoided this by linearising the inner problem, which gives one-step attacks such as the fast gradient sign method.
The outer minimisation is non-convex. Training a deep network is already non-convex. The question is whether gradient steps on the adversarial loss still make progress when the inner problem is only solved approximately.
The paper answers both questions experimentally and with a theorem from optimisation, and it then uses those answers to train networks.
How it works
The method has three parts: a worst-case attack, a check that the attack is strong, and training on its outputs. The walkthrough below uses a one-dimensional toy in place of an image, because the paper's own numbers come later.
- Fix an allowed region. Take the input and a budget . The allowed inputs form the interval from 0.4 to 0.6. Check: the interval has width .
- Pick a loss to maximise. Use . The attacker wants large, which means far from 0.8. Check: at the loss is 0.16, and at it is 0.04, so 0.4 is the worst point in the interval.
- Start at a random point. The paper restarts from random points in the allowed region. Start at , where .
- Take a signed gradient step. The gradient is , which is negative, so the sign step with moves to , where . Check: the loss went up.
- Repeat, and project back. Steps continue to () and to (). The next step would give 0.35, outside the region, so the projection returns it to 0.40. Check: the loss stops rising at its maximum over the interval.
- Train on the attacked input. Compute the loss at the final point, , and take a gradient step on the model parameters using that point. Repeat for many inputs and many epochs. The paper argues the model improves because each gradient is taken at a near-worst case.
Diagram of one training step on a batch:
flowchart LR B["clean batch"] --> P["PGD: random start, signed steps, projection"] P --> A["adversarial batch"] A --> G["gradient of loss at adversarial inputs"] G --> U["SGD update of model parameters"] U -->|"next batch"| B
The math
The saddle point problem
The central object is the min-max problem. The paper writes it as
Here is the data distribution and is the perturbation. The inner maximum is the attack, and the outer minimum is the training. The paper uses as the ball of radius : every coordinate of lies between and .
Step 2 in symbols: the inner attack
The one-step fast gradient sign method sets
where takes the sign of each coordinate. The multi-step projected gradient descent attack iterates
with step size and projection onto the allowed set. In the toy of the walkthrough, and the projection clips to the interval .
Step 3 in symbols: the outer update
Differentiating the inner maximum is the key point. Danskin's theorem says that, for a maximum over a compact set of a smooth function, the gradient of the maximum equals the gradient at the maximiser when that maximiser is unique. The paper therefore takes the gradient of the loss at the adversarial input :
and a gradient step on using is a descent direction for . The paper notes that the theorem's assumptions fail in practice, because ReLU and max-pooling are not smooth, and the inner maxima are approximate. Its experiments suggest that the training still works well enough in practice, and that the value of the saddle point problem falls as capacity grows.
Worked examples
- Start from , where , and the gradient is .
- The sign of the gradient is . The fast gradient sign step is , which is .
- The loss at 0.45 is .
- Interpretation: one large step reaches 0.45. Iterated PGD reaches 0.40 and a loss of 0.16, so the multi-step attack finds a stronger point, which is the paper's reason for preferring PGD.
The paper reports that a standard MNIST network reaches 99.2 percent accuracy on clean inputs, and that FGSM at drops it to 6.4 percent.
- Compute the drop for the standard network under FGSM: percentage points.
- The adversarially trained MNIST network has clean accuracy 98.8 percent in Table 1, and 89.3 percent under PGD with 100 steps and 20 restarts, the strongest white-box attack in the table.
- Compute its drop: percentage points.
- Interpretation: the robust network loses 9.5 points to its strongest attack, while the standard network loses 92.8 to FGSM. The clean-accuracy cost in this table is small.
- Caution: the two numbers come from different attacks, FGSM on the standard network and PGD on the robust one. The comparison shows the scale of the effect, not a controlled gain from one change.
Appendix Table 5 lists, for the wide architecture, a standard network and a PGD-trained network at . The standard network has 95.2 percent clean accuracy and 3.5 percent under 20-step PGD. The PGD-trained network has 87.3 percent clean and 45.8 percent under the same attack.
- Robustness gained: points.
- Clean accuracy given up: points.
- Interpretation: the defence costs about 8 points of clean accuracy and gains about 42 points under the iterative attack. The paper still calls the CIFAR-10 robustness "far from satisfactory".
Try it: a model has 94.0 percent clean accuracy and 10.0 percent under PGD, and a second model has 88.0 percent clean and 40.0 percent under PGD. Which trade is better by the difference in each column? Answer: the second gains 30.0 points of robustness and loses 6.0 points of clean accuracy, so it is the larger trade, and whether it is better depends on how the application weighs clean accuracy against attack resistance.
Results
The paper reports results on MNIST and CIFAR-10, all with -bounded perturbations, and each number below is copied from the paper's text or tables.
- MNIST, white-box (Table 1). The network has two convolutional layers with 32 and 64 filters, each followed by max-pooling, and a fully connected layer of 1024 units. It was trained and tested at with 40 PGD steps of size 0.01. Clean accuracy is 98.8 percent. Accuracy under PGD with 100 steps and 20 restarts is 89.3 percent, and under PGD with 40 steps and 1 restart it is 93.2 percent.
- MNIST, black-box (Table 1). Transfer from an independently trained copy of the network gives 95.7 percent under PGD with 100 steps and 20 restarts. From the architecture B of Tramer et al., the best attack gives 95.4 percent.
- CIFAR-10, white-box (Table 2). Training used 7 PGD steps of size 2 at . The wide network has 87.3 percent clean accuracy, 45.8 percent under 20-step PGD, which the introduction rounds to 46 percent. Under a Carlini-Wagner attack it gives 46.8 percent.
- CIFAR-10, black-box (Table 2). Transfer from an independent copy gives 64.2 percent under 7-step PGD. The introduction reports 64 percent.
- Capacity (Section 4). On MNIST the paper doubles the filter counts and hidden size, starting from 2 and 4 filters and a 64-unit layer. On CIFAR-10 a ResNet widened by a factor of 10 reaches 95.2 percent clean accuracy when trained on natural examples.
- Learned MNIST filters (Appendix C). The robust network uses only 3 of its 32 first-layer filters, and each uses one non-zero weight, so each acts as a thresholding filter.
- Limits. Results are for two datasets and one architecture family. The authors say the CIFAR-10 result is still far from satisfactory. On the MNIST result, PGD fails to find attacks at . The paper says later work found PGD overestimates this robustness, possibly because of gradient masking.
Common mistakes and tradeoffs
It is tempting to think that a model trained with FGSM is robust. In fact the paper finds that FGSM training makes the network overfit the one-step examples, a behaviour called label leaking. Those networks have poor clean accuracy and no robustness against PGD, because the one-step attack gives a narrow set of examples to memorise. FGSM is a reasonable training adversary only when is small, where the loss is nearly linear around each input.
It is tempting to think that the model is safe against all attacks once it resists PGD. In fact the paper treats PGD as its strongest first-order attack and conjectures that robustness to PGD carries over to other first-order attacks. That is a claim the experiments support, not a proof. Subsequent work found that PGD overestimates the robustness of the paper's MNIST model, and the paper suggests this may come from learned threshold filters masking gradients.
It is tempting to think that capacity does not matter. In fact the paper finds that small networks trained against PGD can fail to learn at all, converging to always predicting one class. The authors conclude that robust classification needs more capacity than natural classification does.
Tradeoffs. PGD training costs many forward and backward passes per batch, for example 40 PGD iterations per step on MNIST in the paper. It also lowers clean accuracy, as the CIFAR-10 example shows. Use it when the threat is an -bounded adversary and the model is large enough to carry both goals. Do not use it on a small model, or as the only check of robustness, since PGD can overestimate robustness when gradients are masked. Simpler alternatives are FGSM training, which is cheap but leaks labels, and standard training, which gives no robustness guarantee.
Reading guide
The paper's sections, in order, with the lessons each one needs.
- Section 1 (Introduction) needs Adversarial Examples and Adversarial Training. Read the contributions list as a map of the rest of the paper.
- Section 2 (Optimisation view) needs Empirical Risk Minimization, Constrained Optimization and Minimax Game. Section 2.1 needs Fast Gradient Sign Method and Explaining and Harnessing Adversarial Examples.
- Section 3 (Towards universally robust networks) needs Gradient Descent and Stochastic Gradient Descent for the training loop, and Rectified Linear Unit (ReLU) and Max Pooling because the paper points out that these make the loss non-smooth.
- Section 4 (Capacity) needs Convolutional Neural Network and Deep Residual Learning for Image Recognition (ResNet) for the two architectures.
- Section 5 (Experiments) needs Cross-Entropy Loss and Vector Norm. The and norms define the attack budgets. The CW attack in Table 2 is the Carlini-Wagner loss from Towards Evaluating the Robustness of Neural Networks.
- Section 6 (Related work) needs Adversarial Examples and Explaining and Harnessing Adversarial Examples for the earlier attacks it compares with.
- Appendix A (Danskin's theorem) needs Chain Rule and the idea of a directional derivative. The theorem itself is stated in the appendix in words and symbols.
- Appendix B (Transferability) needs Adversarial Examples and Cross-Entropy Loss; it compares gradients of the loss across independently trained networks.
Check yourself
QuestionWhy does the paper prefer a multi-step attack such as PGD over a single FGSM step when training?Show answer
A single step follows the gradient at one point and can land short of the worst case. In the toy, one FGSM step reaches a loss of 0.1225, while iterated PGD with projection reaches 0.16. Training on the stronger attack gives the model a harder target, which is why the paper argues PGD is the better inner solver.
QuestionThe standard MNIST network has 99.2 percent clean accuracy and 6.4 percent under FGSM at . What is the drop in percentage points?Show answer
percentage points.
QuestionWhy does the paper find that training against FGSM fails, even though FGSM is a valid attack?Show answer
The one-step adversary produces a narrow set of examples, and the network overfits to them, a behaviour called label leaking. Those networks have poor clean accuracy and do not resist PGD, so the training matches the attack and not the robustness goal.
QuestionA paper says its model is robust to all first-order attacks. What is the difference between a conjecture and a proof here?Show answer
The paper conjectures that robustness to PGD extends to other first-order attacks and supports this with experiments on several attacks and transfer settings. A proof would show it for every such attack. Subsequent work found that PGD overestimates the robustness of the paper's MNIST model, which the paper suggests may be due to gradient masking by its threshold filters.
QuestionIn the CIFAR-10 example, how many points of clean accuracy does the PGD-trained wide network give up, and how many does it gain against 20-step PGD?Show answer
It gives up points of clean accuracy and gains points of robustness, relative to the standard wide network.
Sources
- Madry, Makelov, Schmidt, Tsipras and Vladu, "Towards Deep Learning Models Resistant to Adversarial Attacks," arXiv:1706.06083, 2017. arxiv.org/abs/1706.06083
- DOI record for arXiv:1706.06083: doi.org/10.48550/arXiv.1706.06083