Learning the Gradient-to-Perturbation Map in Fast Adversarial Training

Adversarial training teaches a classifier to resist small, deliberately chosen input perturbations by training it on such perturbations. It is expensive because each training batch first needs an attack. The standard attack is projected gradient descent (PGD), which takes many gradient steps on the input and costs roughly ten forward-backward passes per batch. Cheap single-step versions take one gradient step and keep only the sign of each pixel's gradient. These suffer from catastrophic overfitting, where robustness to real multi-step attacks suddenly collapses to zero partway through training. Robust models also lose clean accuracy, and the methods that recover it add cost on top: PART computes saliency maps, and HAT runs a teacher model on extra examples.

We propose replacing the hand-designed step that turns one input gradient into a perturbation with a small learned network. This network takes the image and its single input gradient and outputs a perturbation with varied per-pixel magnitudes and per-pixel budgets. It is trained to keep up with the changing classifier using gradients that the classifier's own weight update already computes, so it adds almost no attack cost. In two sentences: single-step adversarial training fails because "sign of the gradient times ε" is a poor, fixed recipe. A tiny generator can learn a better recipe at the same per-batch cost by recycling the input gradient from the backward pass that already happens, and that recipe can also learn to spend less perturbation budget where it only hurts clean accuracy.

Core Claim

Single-step adversarial training already pays for two backward passes through the classifier. The first computes the input gradient used to build the attack. The second updates the weights, and with negligible extra work it also returns the gradient of the training loss with respect to the perturbed input. The second gradient is exactly the signal needed to train a perturbation generator to increase the loss. Current methods throw it away.

We write the perturbation as

$$\delta = \epsilon \odot m_\phi(x, g) \odot \tanh\big(G_\phi(x, g)\big), \qquad g = \nabla_x \mathcal{L}(f_\theta(x + u), y),$$

where $x$ is the image, $y$ its label, and $f_\theta$ the classifier. The input gradient $g$ is taken at a random start $u$, as in standard single-step training. $G_\phi$ is a small convolutional network with parameters $\phi$ that outputs a signed per-pixel direction. $m_\phi \in [\epsilon_{low}/\epsilon, 1]$ is a learned per-pixel budget fraction, and $\epsilon$ is the attack budget, so $\delta$ always stays inside the $\ell_\infty$ ball.

The classifier minimizes $\mathcal{L}(f_\theta(x+\delta), y)$ as usual. The generator ascends a capped loss,

$$\max_\phi \; \min\big(\mathcal{L}(f_\theta(x+\delta), y),\; \tau\big) - \lambda \, \|m_\phi\|_1,$$

where $\tau$ is a loss cap. The cap stops the generator from pushing an example that is already misclassified even further. This is our cheap stand-in for HAT's finding that over-pushed examples create excessive margins. The term weighted by $\lambda$ makes the generator spend full budget only where it buys loss. The gradient with respect to $\phi$ comes from the classifier's input gradient at $x+\delta$, which the weight-update backward pass already produced, chained through the generator.

The new claim has three parts, all measured at FGSM-level wall-clock cost:

  1. The learned map prevents catastrophic overfitting at ε=16/255, where hand-designed single-step maps fail or only delay it.
  2. The learned budget recovers part of the clean accuracy that PART and HAT recover, without their saliency or teacher passes.
  3. Conditioning on $g$ is essential. A purely amortized generator that sees only $x$ falls behind the moving classifier.

Relation to Prior Work

Two lines of work motivate the proposal by exposing the gap.

The first is fast single-step adversarial training. I-PGD-AT argues that PGD succeeds because its perturbations take diverse magnitudes, whereas sign-based steps are stuck at ±ε. It assigns discrete magnitude levels from the gradient-magnitude distribution with a fixed rule, and reports that catastrophic overfitting is delayed but not eliminated. We keep its diagnosis but make the map learned and adaptive, which is the most direct test of whether its residual failure comes from the rule being fixed. RAT prevents overfitting with a Douglas-Rachford splitting step, an optimization technique that separates loss minimization from a step that regularizes sudden loss changes. It leaves the attack itself sign-based and does not address clean accuracy.

The second line is clean-accuracy recovery. PART gives full budget to object pixels and a reduced budget to background pixels using GradCAM saliency maps, at about twice the training time. HAT limits excessive margin with helper examples labeled by a standard teacher on top of PGD-10. Both show the trade-off is partly an artifact of how the budget is spent. We replace their external guidance with a budget the attacker learns, at no extra pass. This also means we inherit their stated risk that a misallocated budget shrinks margins below ε, which the evaluation must check.

Amortized attackers supply the method. UEA and the Anti-Reference noise encoder produce perturbations in a single forward pass (0.01 s and 0.21 s per image), but only against fixed targets. Rob-GAN puts a generator inside adversarial training, but that generator synthesizes images while real images are still attacked with PGD.

The research file flags the central tension: a generator trained against a moving classifier goes stale, and retraining it per step recreates the inner loop. Our design answers this in two ways. First, it feeds the generator the current gradient, so it never has to predict the classifier from the image alone. Second, it updates the generator every step from gradients that are already free.

Research Program

The first stage builds the training loop and its cost accounting. Each step runs:

  1. A forward-backward pass at $x+u$ to obtain $g$.
  2. A generator forward pass.
  3. One forward-backward pass of the classifier at $x+\delta$, which returns both the weight gradient and $\partial\mathcal{L}/\partial\delta$.
  4. A generator backward pass.

The generator is three to five convolutional layers at input resolution. We will report wall-clock time and peak memory against FGSM-RS on the same GPU, targeting at most 1.2× FGSM-RS time. There is no double backpropagation and no Hessian, which avoids the memory problem of gradient penalties.

The second stage is analysis. We will track PGD-50 robust accuracy on held-out data every epoch, because catastrophic overfitting shows up as a sudden drop. Alongside it we will log the generator's achieved loss relative to a PGD-10 attack on the same batch, which measures how far the amortized attack falls short of the iterative optimum. We will also log the entropy of perturbation magnitudes, to test I-PGD-AT's diversity hypothesis directly, and how well the learned budget map agrees with GradCAM, to see whether the generator rediscovers PART's object/background split on its own.

The third stage covers the obvious failure modes. To check for gradient masking (flat gradients that fool weak attacks), we evaluate with AutoAttack and a transfer attack from a PGD-trained model. To check for mode collapse into a fixed template, we measure how much $\delta$ varies across inputs of the same class.

Baselines

The naive reference is FGSM with random initialization (FGSM-RS). It defines the cost we must match and is known to collapse at ε=16/255. We run it with the same architecture (PreAct ResNet-18), schedule, epochs and augmentation as our method, with step size tuned over the same small grid we give our own hyperparameters ($\tau$, $\lambda$, generator learning rate). Beating it means avoiding collapse at all, which is a low bar.

The strongest fast competitor is RAT. Its paper reports 19.58% AutoAttack robust accuracy on CIFAR-10 at ε=16/255 in 1.7 hours, against 15.36% for Fast-GA, 16.31% for LLR and 6.3 hours for PGD-AT. Its paper reports no clean accuracy figure, so we will retrain it ourselves under our settings and report both. Beating RAT means at least matching that AutoAttack number within seed variance at comparable wall-clock time, while delivering higher clean accuracy. A gain on only one axis would be reported as such.

I-PGD-AT is the closest mechanism. No numeric result was found on Lacuna for I-PGD-AT, so we reimplement it. It doubles as the key ablation: our pipeline with the learned network replaced by I-PGD-AT's fixed magnitude rule isolates whether learning the map matters.

On the clean-accuracy side, HAT is the strongest reference. Its paper reports about 2.17% clean accuracy over TRADES at about 49% AutoAttack robust accuracy on CIFAR-10 with PreAct ResNet-18. PART reports 1.2% to 3.18% clean gains at about twice the training time of standard adversarial training. Both run with PGD and will be reported at their own cost as an upper reference. PGD-10 adversarial training is the cost ceiling. Our success criterion is to close at least half of the clean-accuracy gap between RAT and HAT at FGSM cost, without losing AutoAttack accuracy.

Further ablations remove one ingredient at a time:

  1. Remove $g$ from the generator input (pure amortization), which tests the staleness tension.
  2. Fix $m_\phi = 1$, a uniform budget, which tests whether the learned budget is what drives clean accuracy.
  3. Remove the cap $\tau$.
  4. Freeze the generator after warm-up.

Why not just…?

Why not just use RAT, which already prevents catastrophic overfitting cheaply? It is a real threat on robustness alone. Our method could end up merely tied with it at ε=16/255. The distinguishing evidence would be clean accuracy, since RAT reports none and the research file notes that its stabilizing penalty may worsen excessive margins. The two methods are also compatible, so we will run RAT's splitting step with our generator in place of its sign-based attack. If that combination beats both, the contribution is the attack and not a rival regularizer.

Why not just take two or three PGD steps instead of one? Every extra step costs a full classifier forward-backward pass, so PGD-2 already costs about 1.5× FGSM-RS. We will run PGD-2 at matched wall-clock time. If it matches us, the learned map is not worth its complexity and we will say so. Our bet is that the generator gets multi-step-like diversity from a recycled gradient rather than a new one.

Why not just penalize the input gradient norm directly? The unified gradient regularization family shows this replaces the inner attack, but it requires double backpropagation that roughly doubles training time. It also relies on a first-order Taylor approximation that the research file notes breaks down at large ε, and its only reported numbers are on MNIST. We include it at ε=8/255 and 16/255 as a cost-matched comparison, not as the main contender.

Why not just train a standalone feed-forward attacker like UEA and reuse it? That is exactly the image-only ablation. A generator that never sees the current gradient has to predict a classifier that keeps changing. If the image-only variant matched the gradient-conditioned one, our explanation for why amortization works here would be wrong.

Proposed Experiments

The main experiments are CIFAR-10 and CIFAR-100 at ε=8/255 and 16/255 with PreAct ResNet-18, scaled to Tiny-ImageNet and an ImageNet setting matching RAT's PGD-50 evaluation. For reference, RAT-BP reports 3.29% against Fast-AT's 2.25% in that ImageNet setting. CIFAR-10-C measures whether the learned budget transfers to natural corruptions, as PART and HAT report. Metrics are:

  1. Clean accuracy.
  2. PGD-50 and AutoAttack robust accuracy.
  3. Wall-clock hours and peak memory on one GPU type.
  4. The epoch at which catastrophic overfitting occurs, if it does, over five seeds.

Three checks decide the outcome:

  1. At ε=16/255 our method shows no collapse in any seed, while I-PGD-AT's fixed rule does under identical training.
  2. The learned-budget model beats the uniform-budget model on clean accuracy at equal AutoAttack accuracy, and does not lose AutoAttack accuracy compared with uniform budgets. A loss there would signal the margin leak warned about in the HAT and PART analyses.
  3. The gradient-conditioned generator clearly beats the image-only generator in robust accuracy, and the gap widens later in training, when the classifier has moved furthest from what an image-only generator could anticipate.

If the third check fails or PGD-2 matches us at equal time, we will conclude that learned perturbation maps add nothing over cheap iterative steps.