Abstract
Vision Transformers (ViTs) have demonstrated remarkable performance across various computer vision tasks but often face a significant trade-off between standard accuracy and adversarial robustness. This paper presents Pyramid Adversarial Training (PyramidAT), a novel approach that utilizes multi-scale spatial perturbations and matched regularization to overcome this limitation. By applying perturbations across multiple scales and ensuring consistency in dropout masks between clean and adversarial samples, PyramidAT simultaneously improves clean accuracy and sets new state-of-the-art benchmarks for out-of-distribution robustness on ImageNet.
Introduction
Deep learning models often struggle to generalize when deployed in real-world environments due to out-of-distribution (OOD) data, such as unusual lighting, common image corruptions, or varying camera angles. Adversarial Training (AT), where models are trained on intentionally perturbed images, is a well-known method to boost a model's robustness against these shifts.
However, a persistent challenge in the field is the documented trade-off: traditionally, AT improves robustness at the direct cost of "clean" (in-distribution) accuracy. This research addresses this problem by designing an adversarial training regimen specifically tailored for Vision Transformers (ViTs) that improves both standard accuracy and OOD robustness simultaneously.
Methodology
The authors introduce two primary innovations to the standard adversarial training pipeline:
1. Pyramid Adversarial Training (PyramidAT)
Standard AT typically generates adversarial examples by tweaking individual pixels. In contrast, PyramidAT perturbs the image at multiple spatial scales simultaneously—for example, at the individual pixel level, the 16x16 patch level, and the 32x32 patch level. This multi-scale approach allows the attack to generate large, structured edits (such as changing the brightness of an entire patch) alongside fine-grained pixel modifications. This forces the model to learn features that are invariant to both local and global distortions.
2. Matched Regularization
In standard AT, regularizers like Dropout are often disabled during the generation of adversarial examples. The researchers found that this creates a training mismatch between the clean and adversarial data streams. To resolve this, they implement "Matched" Dropout and Stochastic Depth, applying the exact same masks to both the clean and adversarial versions of an image within a single training step. This consistency is crucial for breaking the accuracy-robustness trade-off.
Experimental Setup and Datasets
To validate the effectiveness of PyramidAT, the authors utilized a comprehensive suite of datasets:
- Training: ImageNet-1K and ImageNet-21K.
- In-Distribution Evaluation: ImageNet-1K, ImageNet-ReaL, and ImageNet-V2.
- Out-of-Distribution (Robustness) Evaluation: A wide array of benchmarks including ImageNet-A (natural adversarial examples), ImageNet-C (common corruptions), ImageNet-R (renditions), ObjectNet (real-world rotations/backgrounds), ImageNet-Sketch, and Stylized ImageNet.
Key Insights
Breaking the Trade-off
The results demonstrate that the clean vs. robust accuracy trade-off is not an inherent law of adversarial training. By combining structured pyramid attacks with matched regularization, models can achieve superior performance in both domains.
Shape over Texture
Frequency analysis reveals that standard pixel-level attacks primarily consist of high-frequency texture noise. Pyramid attacks, however, alter the low-frequency structural components of the image. This shift trains the model to rely more on the global shape of objects rather than local textures, which is a key driver for OOD generalization.
Attention Spread
Visualizations of the models' attention maps indicate that pixel-level AT causes models to focus too narrowly on the center of objects, ignoring useful context. PyramidAT encourages the model to spread its attention more evenly across the entire image, leading to more robust feature extraction.
Results and Performance
PyramidAT achieves significant gains across the board:
- Standard Accuracy: For a ViT-B/16 model trained on ImageNet-1K, clean accuracy improved by +1.82%, reaching 81.71%.
- Robustness Metrics: The method boosted performance across seven robustness metrics by absolute margins ranging from +1.76% to +15.68%.
- State-of-the-Art: The technique set new SOTA records (without extra data) on ImageNet-C (41.42 mCE), ImageNet-R (53.92%), and ImageNet-Sketch (41.04%).
- Architecture Agnostic: Beyond ViTs, the authors demonstrated that PyramidAT also enhances the performance of ResNets, MLP-Mixers, and Discrete ViTs.
Limitations and Future Work
The primary drawback of this approach is the increased computational cost during training. Generating adversarial examples via multi-step Projected Gradient Descent (PGD) requires multiple forward and backward passes, significantly extending training time. However, inference speed remains unaffected. Future research may explore using different optimizers for attack generation to further refine the structural nature of the perturbations for tasks like semi-supervised segmentation.
Summary updated