Abstract
While adversarial training is the gold standard for defending neural networks, models often "overfit" to specific attacks used during training and fail against unseen ones. This paper reveals that Vision Transformers (ViTs) generalize significantly better to diverse adversarial attacks than CNNs, primarily because their attention mechanisms naturally promote weight sparsity, which theoretically and empirically reduces the robustness generalization gap.
Introduction
Deep Neural Networks (DNNs) are notoriously vulnerable to adversarial examples—tiny, human-imperceptible perturbations that flip a model's prediction. To counter this, researchers use Adversarial Training (AT), where the model is trained on these malicious examples.
However, AT suffers from a major "generalization gap." A model trained to resist $\ell_\infty$-norm attacks (which limit the maximum change to any single pixel) might remain completely defenseless against $\ell_1$ or $\ell_2$ attacks. This is known as the adversarially robust generalization problem. While we have some understanding of how data size or training techniques affect this gap, the role of architectural design (e.g., CNNs vs. Transformers) has remained largely unexplored until now.
Methods
The authors conducted a massive empirical study followed by a rigorous theoretical deep dive:
- Large-Scale Benchmarking: They evaluated 20 representative architectures, including classic CNNs (ResNet, VGG), pure Transformers (ViT, DeiT), and hybrids (CoAtNet, CvT).
- Multi-Attack Evaluation: Models were trained using standard $\ell_\infty$ adversarial training but tested against a battery of attacks ($\ell_\infty, \ell_2, \ell_1$, and AutoAttack) to measure "worst-case" robust accuracy.
- Theoretical Lens: They used Rademacher complexity—a measure of a function class's ability to fit random noise—to bound the generalization error. They specifically looked at how weight norms and sparsity influence this complexity.
- Sparsity & Landscape Analysis: The team visualized weight distributions (histograms) and loss landscapes to see how different architectural "ingredients" (like attention vs. convolution) behave under the stress of adversarial training.
Key Insights and Ideas
CNNs as "Attack Overfitters"
CNNs (like ResNet) tend to achieve high accuracy on the specific attack they were trained on but collapse when faced with different $\ell_p$-norms. They essentially "memorize" the noise patterns of one attack type.
The Sparsity Secret Sauce
Transformers, particularly models like PVTv2 and CoAtNet, exhibit much higher weight sparsity than CNNs. In these models, a vast majority of weights are near zero. Theoretical analysis showed that $\ell_1$-norm constraints (which lead to sparsity) reduce Rademacher complexity. The authors found that attention blocks are the primary drivers of this sparsity, making the model's "worst-case" performance much more stable across different attack types.
Loss Landscape Flip
Usually, adversarial training makes a model's loss landscape "sharper" (more sensitive to weight changes). Interestingly, for Transformers, adversarial training actually made the loss landscapes flatter compared to standard training, which is a classic indicator of better generalization.
Key Results
- Worst-Case Champions: In CIFAR-10 tests, PVTv2 and CoAtNet achieved the highest worst-case robust accuracy (~32-33%), while standard CNNs like ResNet lagged behind at ~14%.
- The $\ell_1$ Gap: The difference was most stark on $\ell_1$ attacks. On CIFAR-10, ResNet dropped to 15.90% accuracy, while PVTv2 maintained 46.14%.
- Sparsity Metrics: On ImageNet, the sparsity ratio of ViT parameters improved from 0.65 to 0.95 when moving from clean to adversarial settings, whereas ResNet remained much "denser."
- Patch Size Matters: For Transformers, smaller patch sizes improved clean accuracy but actually made the models more like CNNs—causing them to overfit to specific attacks and reducing their general robustness.
Limitations and Future Work
The authors highlight a few "non-trivial" challenges:
- The Clean-Robust Trade-off: While $\ell_1$ regularization can force CNNs to be sparser and thus more robustly generalizable, it often comes at the cost of significantly lower accuracy on clean (non-adversarial) images.
- Common Corruptions: Interestingly, while Transformers win on adversarial generalization, CNNs often still perform better on "common corruptions" (like fog or blur) on certain datasets. The authors suggest that adversarial noise and natural corruptions might be drawn from very different distributions.
The paper concludes that the next generation of robust AI should likely favor hybrid architectures that lean heavily on global attention mechanisms to maintain the sparsity required for true adversarial generalization.
Summary updated