Going Further: Flatness at the Rescue of Early Stopping for Adversarial Example Transferability

Martin Gubri, Maxime Cordy, Yves Le Traon

TL;DR

Early stopping improves the transferability of adversarial attacks not because it captures "robust features," but because it prevents the model from settling into sharp, highly specific minima in the loss landscape. By explicitly optimizing for flat minima using Sharpness-Aware Minimization (SAM) with an unusually large neighborhood, the authors consistently outperform early stopping by up to 28.8 percentage points, setting a new standard for training surrogate models.

What Problem Does This Paper Address?

Adversarial examples—inputs intentionally designed to trick machine learning models—often possess a fascinating property called transferability. An adversarial perturbation crafted to fool a known "surrogate" model can frequently fool an entirely unknown "target" model. This enables dangerous black-box attacks where an attacker doesn't need direct access to the target system.

To defend against or study these attacks, researchers try to train the best possible surrogate models. Historically, early stopping was the gold standard: stopping the surrogate's training early dramatically boosted attack transferability. The prevailing theory was that deep networks learn broad, robust features early in training and brittle, non-robust features later.

This paper challenges that feature-centric assumption. The authors ask: What if the secret to early stopping isn't about the features themselves, but the geometry of the loss landscape the model explores during training?

Methods

The authors approach the problem by shifting focus from feature space to parameter space geometry:

  1. Hypothesis Refutation: They first test the traditional "robust vs. non-robust features" hypothesis by training surrogates on specially modified datasets containing only robust or non-robust features.
  2. Loss Landscape Analysis: They track the geometry of the loss landscape during standard SGD training, measuring sharpness via the largest eigenvalue and the trace of the Hessian matrix.
  3. Sharpness-Aware Minimization (SAM): Instead of relying on early stopping to implicitly find good geometry, they propose using SAM and its variants (like AGSAM and LookSAM) to explicitly minimize loss sharpness.
  4. Large-Neighborhood Regularization (l-SAM): Crucially, they discover that the standard neighborhood size ($\rho = 0.05$) used to maximize standard accuracy is suboptimal for transferability. They introduce l-SAM, which uses an unusually large neighborhood ($\rho = 0.3$ to $0.4$) to force the model into exceptionally flat regions of the parameter space.
Figure 1: Illustration of the loss landscape, showing the training of surrogate models to craft transferable adversarial examples. Before the learning rate decays, training tends to “cross the valley” with plateauing transferability. A few iterations after the decay of the learning rate, early stopped SGD achieves its best transferability (gray). In the following epochs, SGD falls progressively into deep, sharp holes in the parameter space with poor transferability (red). l-SAM (blue) avoids these holes by minimizing the maximum loss around an unusually large neighborhood (thick blue arrow).

Datasets

The experiments were conducted using standard computer vision benchmarks:

  • CIFAR-10
  • ImageNet
  • Robust/Non-robust CIFAR-10 variants: Datasets derived from Ilyas et al. (2019) ($D_R$, $D_{NR}$, $D_{rand}$, and $D_{det}$) specifically engineered to isolate robust and non-robust features.

Key Insights and Ideas

  • The Feature Hypothesis Fails: Surrogates trained on purely robust features and purely non-robust features show identical transferability curves over training epochs. Early stopping helps both equally, meaning the "robust features first" theory cannot explain why early stopping works.
  • The Learning Rate Connection: Transferability peaks abruptly right after a learning rate decay. When the learning rate drops, the model stops bouncing around the top of the loss valley and crawls down to the bottom, temporarily hitting a flat region.
  • Sharp Holes are Transferability Traps: As standard SGD training continues past its peak, the model falls into deep, sharp holes in the loss landscape. These sharp minima represent highly overfitted, model-specific representations that yield poor adversarial transferability.
Figure 5: Sharpness drops when the learning rate decays. Largest eigenvalue of the Hessian (red) and trace of the Hessian (blue) for all training epochs (x-axis) on CIFAR- 10. Average success rate on ten targets (orange, right axis). Average (line) and confidence interval of ± two standard deviations (colored area) of three training runs. Vertical bars indicate the learning rate step decays. Best seen in colors.

Key Results

  • Explicit Flatness Beats Early Stopping: Sharpness-aware optimizers consistently outperform standard early-stopped SGD. On ImageNet, a surrogate trained with large-neighborhood AGSAM (l-AGSAM) achieved an adversarial success rate of 53.14%, compared to just 19.97% for early-stopped SGD.
  • Massive Gains on CIFAR-10: On CIFAR-10, l-SAM and l-AGSAM achieved transferability success rates of ~85.5%, outperforming early-stopped SGD (70.16%) and fully trained SGD (56.06%).
Figure 6: SAM variants and SWA improve transferability over SGD, and SAM with large neighborhoods over the original SAM. Average success rate evaluated over ten target models from a ResNet-18 surrogate model trained for a number of epochs (x-axis) on ImageNet (left), and from a ResNet-50 on CIFAR-10 (right). SAM and its variants are trained with both the original size of flat neighborhood (dotted, ρ = 0.05 except ρ = 0.5 for adaptive variants) and the larger size that we tuned for transferability (plain). Red is our standard SGD surrogate. Best seen in colors.
  • Complementary to Existing Attacks: When l-SAM is used as the base surrogate model, it amplifies the power of existing transferability techniques (like data augmentations or attack optimizers) across the board, boosting success rates by up to 35.5 percentage points.

Limitations and Future Work

  • Natural Accuracy Trade-off: The massive neighborhood size ($\rho$) required to maximize transferability acts as a very strong regularizer, which can slightly degrade the model's standard clean accuracy (e.g., dropping ResNet-18 top-1 accuracy on ImageNet from 69.84% to 67.89%).
  • Minor Method Conflicts: While l-SAM stacks beautifully with data augmentation and attack optimizers, it shows a slight conflict with certain model augmentation techniques like LGV, which rely on standard SGD trajectories.
  • Future Directions: The authors suggest that future work should explore adapting trajectory-based model ensembling techniques to work harmoniously with sharpness-aware optimization.

Summary updated

BibTeX
@misc{gubri2023going,
  author = {Martin Gubri and Maxime Cordy and Yves Le Traon},
  title = {{Going Further: Flatness at the Rescue of Early Stopping for Adversarial Example Transferability}},
  year = {2023},
  eprint = {2304.02688},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.02688},
}
Figure