A projected gradient descent attack (PGD attack) is an iterative white-box method for crafting adversarial examples: it repeatedly moves an input in the direction that increases the model loss and, after every step, projects the result back into a small set of allowed perturbations around the original input. In AI security, PGD is the standard first-order attack used to measure how robust a neural network is against evasion.
The attack was popularized in 2017 as the inner loop of adversarial training, where it serves as a strong approximation of the worst-case perturbation. Because it is simple, reliable and cheap compared with optimization-based attacks, PGD has become the reference benchmark that robustness claims are expected to survive.
How the PGD attack searches for adversarial examples
PGD solves a constrained maximization problem: find a perturbation delta that maximizes the loss of the model on input x plus delta, subject to the norm of delta staying within a budget epsilon. It approaches the solution with gradient steps and enforces the constraint by projection.
- Start from the clean input, or from a random point inside the epsilon ball.
- Compute the gradient of the loss with respect to the input.
- Take a step of size alpha in the gradient direction; for the L-infinity norm, use the sign of the gradient.
- Project the perturbed input back into the epsilon ball and the valid data range, for example pixel values between 0 and 1.
- Repeat for a fixed number of iterations and keep the most damaging result.
The update for the L-infinity case can be written as x_next = clip(x + alpha * sign(grad), x0 - eps, x0 + eps). The random start matters: running several restarts from different random points helps escape weak local maxima and gives a more reliable estimate of the worst case.
Key parameters of a PGD attack
The strength of a PGD attack is defined by a small set of parameters, and robustness results are only comparable when these values are reported. The table summarizes the parameters with values commonly used for image benchmarks.
| Parameter | Meaning | Typical value | Effect when increased |
|---|---|---|---|
| Epsilon | Maximum perturbation size | 8/255 under L-infinity on CIFAR-10 | Stronger attack, more visible change |
| Step size alpha | Distance moved per iteration | 2/255 or about epsilon/4 | Faster progress, risk of overshooting |
| Iterations | Number of gradient steps | 10 for training, 20 to 100 for evaluation | Stronger attack, higher cost |
| Random restarts | Independent attack runs | 1 to 10 | Better worst-case estimate |
| Norm | Geometry of the threat model | L-infinity or L2 | Changes the shape of allowed changes |
| Loss function | Objective being maximized | Cross-entropy or margin loss | Margin loss resists some masking |
A targeted variant minimizes the loss for a chosen wrong class instead of maximizing the loss for the true class. This is useful when an attacker needs a specific outcome, such as a stop sign classified as a speed limit sign.
PGD compared with other evasion attacks
PGD sits between the very fast fast gradient sign method and expensive optimization attacks. It is often described as a multi-step version of FGSM with projection.
| Attack | Access needed | Iterations | Typical role |
|---|---|---|---|
| FGSM | White-box gradients | One step | Quick baseline, cheap training |
| PGD | White-box gradients | 10 to 100 steps | Standard robustness benchmark |
| Carlini–Wagner attack | White-box gradients | Hundreds to thousands | Minimal-norm perturbations |
| DeepFool | White-box gradients | Few, adaptive | Estimating distance to the decision boundary |
| AutoAttack | White-box and score queries | Ensemble of attacks | Parameter-free robustness evaluation |
| Transfer attack | Surrogate model only | PGD on surrogate | Black-box attack via adversarial transferability |
Because PGD uses only first-order information, it is considered close to the strongest first-order adversary. Models that resist well-tuned PGD usually also resist other gradient-based attacks, although AutoAttack is now preferred for final evaluations.
PGD in adversarial training and evaluation
PGD is used both to attack models during testing and to harden models during training. In PGD adversarial training, each training batch is replaced or augmented with PGD examples, so the model learns to classify correctly inside the epsilon ball.
| Goal | Recommended setup | Reason |
|---|---|---|
| Adversarial training | 7 to 10 steps, one random start | Balances robustness and training cost |
| Robustness evaluation | 50 to 100 steps, several restarts | Approximates the true worst case |
| Red teaming a deployed model | PGD on a surrogate, then transfer | Real attackers rarely see gradients |
| Checking a new defense | Adaptive PGD against the full pipeline | Exposes gradient masking |
Adversarial training with PGD typically costs several times more compute than standard training and lowers clean accuracy by a noticeable margin. This robustness-accuracy trade-off is one of the central open problems in adversarial machine learning.
Limitations and pitfalls in PGD evaluations
A PGD result shows that a model is not robust when the attack succeeds, but a failed attack does not prove robustness. Several well-known mistakes inflate reported security.
- Gradient masking: defenses that obscure or shatter gradients make PGD fail while the model remains vulnerable to other attacks.
- Too few iterations or restarts underestimate the worst case and overstate robustness.
- Non-adaptive evaluation ignores preprocessing or randomness that an attacker would account for.
- Narrow threat models: robustness against L-infinity at 8/255 says little about patches, rotations or physical attacks.
- No guarantee: only certified methods such as randomized smoothing provide provable bounds.
In simple terms
Think of a picture that a model labels correctly. A PGD attack changes the picture in tiny steps. Each step is chosen to confuse the model a little more. After every step, the attack checks one rule: the picture must stay almost identical to the original.
After a few dozen steps, a person still sees the same image. The model, however, may now give a completely wrong answer. Security teams run this attack on purpose. It reveals how easily a model can be fooled before real attackers try it.
A practical example
A company that builds traffic sign recognition for driver assistance evaluates a new classifier before release. The model reaches over 98 percent accuracy on clean test images, and the safety team must check how it behaves under small, deliberate perturbations.
The team runs an L-infinity PGD attack with epsilon of 8/255, step size 2/255, 50 iterations and five random restarts. Robust accuracy collapses to under 5 percent, and many stop signs become speed limit signs after changes invisible to a human reviewer.
The engineers retrain the classifier with PGD adversarial training using 10 steps per batch. Clean accuracy falls by a few points, but robust accuracy under the same evaluation and under AutoAttack rises to roughly half of the test set. The report documents all parameters, so later model versions can be compared on equal terms.