- Introduced by
- Aleksander Madry et al.
- Year
- 2018
- Type
- Robust optimization training procedure
- Family
- Training techniques
What does it do?
Adversarial Training is a robust optimization procedure for deep neural networks in which the model is trained on worst-case perturbed inputs generated during training, rather than on clean data alone.
Formalized by Madry et al. (2018) as a min-max saddle-point problem, the method uses Projected Gradient Descent (PGD) to find perturbations within a bounded Lp ball before each parameter update. The aim is to learn decision boundaries that stay stable under perturbations of that size.
The intuition behind the method
Consider a classifier that has only seen clean examples: a small, deliberately chosen change to an input can flip its prediction. Adversarial training changes the training data by pairing each example with the most damaging nearby input an attacker can produce under a fixed budget, and then updating the model so that it classifies that perturbed input correctly. Training therefore alternates between an attacker step, which searches for a harmful perturbation, and a learner step, which adjusts the weights against it. The process does not guarantee a stable end state, but it pushes the model toward decision boundaries that are harder to cross within the chosen budget.
History
Madry et al. (2018) recast adversarial training as a saddle-point optimization problem and argued that PGD-based inner maximization yields a universal first-order adversary within the threat model, which provided the formulation on which this method is based.
When to use it
Choose adversarial training when a model will operate where inputs may be deliberately manipulated, and when the threat can be described as a perturbation of bounded Lp size, as in some malware detection or perception settings. The method assumes that the training attack can use the model's own gradients (a white-box setting) and requires a chosen perturbation budget epsilon. Avoid it when compute is tightly limited, because each update needs several extra forward and backward passes for the inner attack, so cost grows with the number of PGD steps. Do not use it when formal certification is required; certified approaches such as randomized smoothing or interval bound propagation are the appropriate alternatives. It is also a poor fit when the relevant threat is not a small norm-bounded change, since the training objective covers only the chosen perturbation set.
Limitations and considerations
- Training cost rises with the number of inner PGD steps, since each outer update requires a multi-step inner search
- Clean accuracy often falls relative to standard training, because the objective rewards invariance within the epsilon-ball even where clean inputs would be classified differently
- Robustness is tied to the norm and budget used in training; a model trained against L∞ perturbations is not guaranteed to be robust to L2 perturbations, and transfer between norms is imperfect
- Provides no formal certified guarantee; an attacker using a larger budget, a different norm, or an attack outside the training assumptions can still succeed
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Targets the worst case inside a specified perturbation set through the min-max objective, so the training signal is tied directly to the threat model rather than to clean accuracy alone
- Requires no change to network architecture or loss function; the inner attack and outer update can be added to an existing training loop, provided the model is differentiable with respect to its input
- Because the inner solver takes multiple steps, it searches for stronger perturbations than a single gradient step such as FGSM, which is why PGD training is the standard formulation rather than single-step training
- Gives a concrete, testable robustness target: empirical robustness can be measured against the same norm and budget used during training
Applications
- Image classification under Lp-bounded perturbations, the setting in which the method was formulated and is most often evaluated, for example on CIFAR-10 benchmarks
- Malware detection, where classifiers operate on feature vectors that an attacker may try to modify to evade detection
- Perception models for autonomous driving, where the threat model must be specified and tested; a bounded-norm formulation covers only part of the threat, such as small perturbations, and not physically realizable patches in general
- Natural language processing, where token inputs are discrete, so PGD-style perturbations are typically applied to continuous embeddings rather than to the tokens themselves
- Medical imaging, where diagnostic models may be exposed to manipulated inputs; the budget must reflect the realistic manipulation threat for the specific deployment
How it works
How it works
For each training mini-batch, an inner maximization problem is solved: find the perturbation delta within an Lp-ball of radius epsilon that maximally increases the model's loss on the current example. This is the adversary's role and it identifies the most damaging input the attacker can produce within the allowed budget.
Formula
\delta^* = \arg\max_{\|\delta\|_p \leq \epsilon} \mathcal{L}(f_\theta(x + \delta), y)PGD is the inner solver. For the L∞ norm, the displayed update takes a step of size alpha in the direction of the sign of the loss gradient with respect to the perturbation, then projects the result back onto the epsilon-ball. The sign operation is specific to L∞. Other norms require a different steepest-ascent step and projection, so the displayed formula should not be read as the general Lp update. The recursion also needs a starting point delta^(0), which the displayed formula does not define. Common choices are zero or a random point inside the ball. This choice is part of the implementation and can affect the strength of the attack. Several iterations are used so that the perturbation is a stronger search than a single gradient step. The number of steps is a trade-off between cost and attack strength, and benchmark settings differ.
Formula
\delta^{(t+1)} = \Pi_{\|\delta\|_p \leq \epsilon}\!\left(\delta^{(t)} + \alpha \cdot \operatorname{sign}\!\left(\nabla_\delta \mathcal{L}(f_\theta(x + \delta^{(t)}), y)\right)\right)The outer minimization updates the model parameters theta to minimize the expected worst-case loss across the data distribution. The gradient is computed with respect to theta, evaluated at the adversarial example delta* found by the inner loop, not at the clean input.
Formula
\theta^* = \arg\min_\theta \mathbb{E}_{(x,y)\sim\mathcal{D}}\!\left[\max_{\|\delta\|_p \leq \epsilon} \mathcal{L}(f_\theta(x + \delta), y)\right]A standard optimizer step is applied using the gradient of the loss at the adversarial example. The weights are updated to reduce this worst-case loss, which moves the decision boundary away from perturbed inputs within the epsilon-ball.
Formula
\theta \leftarrow \theta - \eta \nabla_\theta \mathcal{L}(f_\theta(x + \delta^*), y)Common pitfalls
- Setting epsilon too large can make the training problem hard to fit and degrade clean accuracy, while an epsilon that is too small gives little robustness benefit
- Using too few PGD steps, such as a single FGSM-style step, can produce gradient masking: the model appears robust to the training attack while remaining vulnerable to stronger multi-step attacks
- Evaluating robustness only against the same PGD attack used in training can overestimate true robustness; always use independent evaluation attacks
- Choosing the inner step size alpha without regard to epsilon and the number of steps leads to poor coverage of the perturbation ball. As a consistency check for the L∞ update, the total movement alpha multiplied by the number of steps should be able to reach the boundary of the ball from a zero starting point. If it cannot, the attack never reaches the edge of the budget it is meant to explore
Frequently asked questions
What is the difference between FGSM training and PGD adversarial training?
FGSM (Fast Gradient Sign Method) training uses a single gradient step to generate adversarial examples. It is cheap, but it can give an apparent robustness that does not hold up against multi-step attacks, a failure mode known as gradient masking. PGD training uses several iterative steps to find stronger adversarial examples, which makes each update more expensive but the trained robustness harder to evade.
Does adversarial training guarantee robustness?
No. Adversarial training provides strong empirical robustness against attacks within the specified threat model but does not offer formal certified guarantees. A sufficiently powerful attacker operating outside the assumed budget or norm can still find adversarial inputs. Methods such as randomized smoothing or interval bound propagation are required when certified robustness is needed.
How should the perturbation budget epsilon be chosen?
Epsilon should reflect the realistic threat level in the deployment context rather than a universal constant. For CIFAR-10 with L∞, epsilon=8/255 is a widely used community benchmark convention, and it should be checked against the actual threat model rather than adopted by default. Too small an epsilon yields negligible robustness; too large causes severe clean accuracy degradation and may make the training problem infeasible. Validate the choice by measuring both clean accuracy and robustness at the selected budget.
What is catastrophic overfitting in adversarial training?
Catastrophic overfitting is a failure mode in which adversarial training with a single-step attack such as FGSM appears to succeed against the training attack while robustness collapses against multi-step attacks such as PGD. The apparent robustness then reflects gradient masking rather than genuine robustness. Detecting it requires evaluating the trained model on held-out data against a stronger multi-step attack. Multi-step PGD training is the usual safeguard when a cheaper single-step attack is considered.
Related methods
Sources
Madry, A., Makelov, A., Schmidt, L., Tsipras, D., & Vladu, A. (2018). Towards deep learning models resistant to adversarial attacks. International Conference on Learning Representations (ICLR).
Open publication reference