Learned Per-Image Elastic Adversaries for Cheap Spatial Robustness

Image classifiers trained to resist small pixel-noise attacks remain easy to fool by gently warping the image, that is, by moving pixels slightly along a smooth displacement field. This proposal trains a small generator network alongside the classifier. For each training image, the generator predicts in one forward pass a smooth, non-rigid warp that the classifier finds hard. It also predicts how strongly that particular image can be warped before it stops being the same object. The classifier is then trained on these warps. The bet is that this one change gives three things at once: robustness to warping attacks close to that of expensive iterative adversarial training, a training cost of roughly twice that of ordinary training rather than ten to twenty times, and a smaller loss of accuracy on clean images, because fragile images are no longer forced through warps that change their label.

This combination matters because the three costs normally trade against each other. Iterative adversarial training, which searches for a worst-case perturbation with many gradient steps before every update, is slow. When every image gets the same perturbation budget, clean accuracy drops, since the model spends capacity defending neighborhoods that either do not need defending or cannot be defended without changing the label. Warping a handwritten "6" far enough produces something that is not a "6", while a "0" tolerates much more. A per-image warp generator addresses the cost and the budget problem with one component.

Core Claim

An amortized elastic adversary can match iterative flow-space adversarial training on warp robustness at a fraction of the cost and with better clean accuracy. "Amortized" means a network learns to output the attack directly instead of solving an optimization for every image. "Elastic" means the warp is a smooth non-rigid field, here a thin-plate spline: a smooth interpolation driven by displacements of a coarse grid of control points. The generator conditions both the direction and the amplitude of the warp on the image. The amplitude is learned from a label-preservation signal supplied by a frozen reference model, not from the current classifier's vulnerability.

That last choice is what separates this idea from simpler per-image schemes. Stopping an attack as soon as the current model errs, or reweighting losses by how quickly the current model breaks, measures the model's weakness rather than the image's semantic tolerance. Those two quantities come apart exactly on the images where clean accuracy is lost.

Relation to Prior Work

Four papers each own one piece of this, and none combines them.

Supplies the per-image policy idea and the affinity constraint. AROID trains a per-image policy over discrete rigid and color transformations with REINFORCE, a high-variance gradient estimator. The policy is guided by vulnerability, affinity-to-a-reference-model, and diversity terms, and reaches 55.91% AutoAttack accuracy on CIFAR-10 while shrinking robust overfitting. We reuse its affinity idea. Unlike AROID, our transformation is continuous and non-rigid, so the generator receives exact gradients through differentiable resampling and needs no REINFORCE. We also target the warp threat model itself, not just pixel-noise robustness.

Supplies the amortization technique. SdpAdv generates an affine transform plus pixel noise in a single forward pass and breaks adversarially trained MNIST models. It is an attack restricted to six affine parameters. We extend amortization to non-rigid fields and use it for defense.

Motivates the threat model. stAdv defines the threat: smooth flow fields regularized by total variation, perceptually indistinguishable from clean images, with about 48% attack success against ensemble adversarially trained MNIST models. Its attack is iterative per image. We use it as the evaluation adversary.

Constrains the design. AdvEigAug shows that adversarially chosen deformations beat random ones for few-shot segmentation, with Dice of 79.1% versus 76.3% on OAI cartilage. It uses a dataset-wide principal-component deformation basis with an inner gradient loop. Our basis is per-image and the loop is gone.

Motivates and constrains the budget mechanism. GAIRAT argues that uniform treatment wastes capacity on points far from the boundary. It reweights losses by the number of attack steps needed to flip each point, but only under pixel noise, and it adapts weights rather than budgets. Pareto Adversarial Robustness finds that pixel-noise robustness correlates positively with local flow robustness but negatively with global rotation-translation robustness. It balances these with a per-step multi-objective solve that is expensive. Our proposal adds no new robustness axes. It makes one axis, local flow, cheap and budget-aware, and it measures whether this hurts the other axes.

Frames the evaluation. TRADES decomposes robust error into natural error plus boundary error and supplies the clean-versus-adversarial consistency loss we train with. It also implies that images whose label changes inside the global budget carry irreducible robust error. That is why we report label-preservation alongside robust accuracy.

Research Program

The generator and the classifier objective. The generator $g_\psi$ takes an image $x$ and outputs a unit-norm control-point displacement $u_\psi(x)$ on a coarse thin-plate-spline grid and a scalar amplitude $a_\psi(x) \in [0, A]$, where $A$ is a hard cap. The warped image is $x' = W(x, a_\psi(x)\, u_\psi(x))$, with $W$ the differentiable spline warp followed by bilinear resampling. The classifier $f_\theta$ minimizes a TRADES-style loss on these warps:

$$\min_\theta \; \mathbb{E}\big[\mathcal{L}(f_\theta(x), y) + \beta\, \mathrm{KL}(f_\theta(x) \,\|\, f_\theta(x'))\big]$$

Here $\mathcal{L}$ is cross-entropy, $y$ the label, $\beta$ the trade-off weight, and $\mathrm{KL}$ the divergence between clean and warped predictions.

The generator objective. The generator ascends

$$\mathbb{E}\big[\mathcal{L}(f_\theta(x'), y) + \eta\, a_\psi(x) - \gamma \max(0,\, \tau - p_{\mathrm{ref}}(y \mid x'))\big]$$

The first term seeks warps the current classifier gets wrong. The term weighted by $\eta$ pushes each image's amplitude toward the cap, so the training distribution covers the evaluation budget wherever it can. The hinge, weighted by $\gamma$, stops growth once a frozen reference model $f_{\mathrm{ref}}$ assigns the true label probability below a threshold $\tau$. A small total-variation penalty on the field, taken from stAdv, keeps warps smooth.

Cost. Each step costs one generator forward and backward pass plus one extra classifier pass. We expect roughly 1.5 to 2 times standard training, against 10 to 20 times for flow-space projected gradient descent (PGD).

The reference model, and how we test its circularity. The reference model is trained once with heavy random elastic augmentation. Its role creates a possible circularity, so we test it directly. On MNIST, a small human-labeling pass on generated warps checks whether the reference model's label-preservation judgments match human judgments.

Failure modes we monitor. Amortized adversaries can collapse to a few easy warps, the analogue of the catastrophic overfitting seen with single-step pixel attacks. We therefore track the diversity of the generator's output. We also always evaluate with strong iterative attacks that are independent of the generator, never with the generator itself.

Baselines

Do-nothing and random-warp references. The do-nothing reference is standard training with crop-and-flip augmentation. Its warp robustness should be near zero, given stAdv's near-100% white-box success. The naive reference is training with random thin-plate-spline warps. Its amplitude distribution is tuned on a held-out split with the same tuning budget as our method. These two rows tell us how much of the gain comes from seeing warps at all.

Strongest existing method. The strongest competitor is iterative flow-space adversarial training. This is stAdv's flow attack, or PGD on the same spline control points, run for 10 steps inside a TRADES loss with a single global budget. It is the most direct way to buy warp robustness and is the method our cost claim must beat. As the published multi-axis reference we also run Pareto Adversarial Training, which reports a Universal Robustness score of 130.96 on CIFAR-10, versus 127.11 for average-loss training. We found no reported result on Lacuna for flow-attack robust accuracy of flow-adversarially-trained CIFAR-10 models, so we will run this baseline ourselves.

Fairness protocol. All methods share a WideResNet backbone, the same data, the same number of epochs, the same hyperparameter-search trials, and the same evaluation budget. We report wall-clock GPU-hours. Beating the iterative baseline means matching its flow robust accuracy to within one point at under a quarter of its GPU-hours, with higher clean accuracy.

Isolating the key ingredient. Two ablations do this. The first fixes $a_\psi(x)$ to a single learned global amplitude, giving an amortized generator without per-image budgets. The second replaces the reference-model hinge with friendly stopping, which halts the amplitude once the current classifier errs. If the full method does not beat both ablations on clean accuracy at equal flow robustness, the per-image budget idea fails.

Pixel-noise reference. We include AROID and TRADES with pixel-noise PGD. TRADES reports 88.64% clean and 56.61% PGD accuracy on CIFAR-10. These rows measure what our warp training gives up or gains on the pixel-noise axis.

Why not just…?

Why not just use random elastic warps with a well-tuned strength? This is cheap and may give some robustness. The existing evidence is that random warps underperform adversarially chosen ones: AdvEigAug reports 76.3% versus 79.1% Dice. It also shows that uniform random transformations can actively hurt sensitive images: in InstaAug, test-time random crops dropped ImageNet accuracy from 80.43% to 79.60%. Both results come from segmentation or cropping, not adversarial warp robustness. The tuned random-warp baseline therefore settles the question directly. If it comes within two points of our flow robust accuracy, the generator is not earning its complexity and we will say so.

Why not just run friendly or GAIRAT-style flow adversarial training, which is already per-image? This is the most serious threat. Early-stopped flow PGD adapts the budget per image and is cheaper than full PGD. Our argument is that stopping at the current model's first error confuses "currently hard" with "label-changing". That confusion should cost clean accuracy on images that are hard but warp-tolerant. The friendly-stopping ablation runs inside our amortized generator, and a full iterative friendly-flow variant runs as a separate baseline, so both cost and budget effects are separated. If friendly stopping matches us, the contribution reduces to amortization alone.

Why not just add random resizing at inference, or robustness tokens on a frozen transformer? Input randomization costs nothing to train. Its authors note it is weakened by attacks that average gradients over random transforms, and it was designed for pixel attacks, not flow fields. Robustness tokens recover 63.1% accuracy under attack on DINOv2-Giant. They require a transformer, assume the tokens stay secret, and were tested only on pixel noise. We evaluate randomization under expectation-over-transformation flow attacks as a reference row. Tokens are out of scope for our convolutional backbone, but a transformer follow-up could train tokens against our generator.

Proposed Experiments

Primary benchmark. CIFAR-10 is primary, with CIFAR-100 as a check for scaling to more classes. MNIST is a diagnostic set where semantic fragility under warping is visible and human-checkable, for example digits that become other digits. Tiny-ImageNet tests whether benefits shrink at higher resolution, which AROID reports for its own method.

Metrics. We report:

  • clean accuracy;
  • robust accuracy under iterative stAdv flow attacks and spline-PGD at three global budgets;
  • PGD and AutoAttack pixel-noise accuracy;
  • rotation-translation accuracy, to test the negative correlation from Pareto Adversarial Robustness;
  • GPU-hours;
  • the robust overfitting gap between peak and final robust accuracy.

Per-image analysis. We bin test images by the warp amplitude at which the reference model, and on MNIST humans, judge the label changed. Robust accuracy is computed only over images where the evaluation budget is label-preserving. This separates real robustness gains from the irreducible error TRADES predicts.

Decisive checks. The proposal succeeds if three things hold together:

  1. Our method lies on or above the iterative flow-adversarial-training frontier of clean accuracy against flow robust accuracy, at under a quarter of its cost.
  2. It beats the global-amplitude and friendly-stopping ablations on clean accuracy at matched robustness.
  3. Its learned amplitudes correlate with human label-tolerance on MNIST better than attack-step counts do.

If the frontier gain appears but the third check fails, the method works for reasons other than semantic budgeting, and we will report it that way.