Vision Transformers are Robust Learners

Sayak Paul, Pin-Yu Chen

TL;DR

Vision Transformers (ViTs) are not just highly accurate—they are inherently robust learners. This paper demonstrates that ViTs significantly outperform state-of-the-art convolutional neural networks (CNNs) across six challenging robustness benchmarks. Through systematic experimentation, the authors show that ViT's superior performance is driven by its global self-attention mechanism, smoother loss landscapes, and lower sensitivity to high-frequency noise.

What Problem Does This Paper Address?

While Vision Transformers (ViTs) have achieved state-of-the-art accuracy on standard image recognition tasks, their robustness to real-world anomalies has remained largely unexplored. Traditional CNNs are notoriously vulnerable to common corruptions (like blur, fog, or digital noise), distribution shifts, and adversarial attacks.

This paper investigates whether ViTs are inherently more robust than CNNs when evaluated under fair conditions (similar parameter sizes and pre-training regimes). Crucially, the authors go beyond simple benchmarking to answer why these architectural differences alter how models handle corrupted or perturbed data.

Methods

The authors conduct a comprehensive evaluation comparing ViT variants against Big-Transfer (BiT)—a state-of-the-art, scaled-up CNN architecture—and standard ResNets. To dissect the root causes of ViT's robustness, they design six diagnostic experiments:

  1. Attention Fusion Analysis: Comparing pure ViTs against CNNs enhanced with spatial or channel attention mechanisms (e.g., EfficientNetV2, Gather-Excite, Selective Kernels).
  2. Pre-training Isolation: Evaluating the specific impact of training on ImageNet-1k versus the much larger ImageNet-21k dataset.
  3. Image Masking (Cutout): Testing model accuracy when varying percentages (up to 50%) of the input image pixels are randomly blocked out.
  4. Fourier Spectrum Analysis: Mapping model sensitivity to perturbations introduced at different spatial frequencies.
  5. Spectral Decomposition of Attacks: Using Discrete Cosine Transform (DCT) to analyze the frequency distribution of adversarial perturbations generated by the DeepFool attack.
  6. Loss Landscape Mapping: Tracking the progression of cross-entropy loss under multi-step Projected Gradient Descent (PGD) adversarial attacks to evaluate optimization smoothness.

Datasets

The study utilizes six distinct ImageNet-derived benchmarks to evaluate different dimensions of model robustness:

  • ImageNet-C: 15 types of algorithmic corruptions (noise, blur, weather, digital) across 5 severity levels.
  • ImageNet-P: Subtle sequential perturbations (tilt, scale, translation, rotation).
  • ImageNet-R: Semantic shifts and abstract renditions (art, cartoons, graffiti, toys).
  • ImageNet-O: Out-of-distribution anomaly detection.
  • ImageNet-A: Natural adversarial examples (real-world images that naturally trigger misclassifications).
  • ImageNet-9: Background dependence and foreground vulnerability.

Key Insights and Ideas

  • Global Context Trumps Local Texture: Unlike CNNs, which rely heavily on local pixel textures and central object alignment, ViT’s self-attention mechanism integrates global context across the entire image from its very first layers. This allows it to maintain high accuracy even when critical portions of an image are missing.
  • Wider Adversarial Energy Spread: To successfully fool a ViT, an adversarial attack must alter almost the entire frequency spectrum. In contrast, CNNs can be easily tricked by low-frequency perturbations alone, making them much softer targets for targeted noise.
  • Smoother Loss Landscapes: ViT exhibits a significantly gentler increase in classification loss during adversarial attacks compared to BiT. This smoother loss landscape makes it harder for gradient-based attacks to find disruptive perturbations.
  • The Attention Advantage: While adding attention blocks (like SE or SK) to standard CNNs noticeably improves their robustness, ViT's pure multi-head self-attention (MHSA) architecture provides a fundamentally superior baseline.

Key Results

  • Massive Gains on Natural Adversaries: On the ImageNet-A dataset, ViT L-16 achieves a top-1 accuracy of 28.10%, which is 4.3x higher than the comparable BiT-m r101x1 (6.41%), despite ViT utilizing fewer parameters.
Figure 4: Top-1 accuracy scores (%) on ImageNet-A dataset.
  • Outperforming Specialized Defenses: On ImageNet-C, ViT L-16 achieves a mean Corruption Error (mCE) of 45.45%, outperforming specialized data augmentation frameworks like DeepAugment + AugMix (53.6%).
Figure 1: Mean top-1 accuracy scores (%) on the ImageNet-C dataset as yielded by different variants of ViT and BiT.
  • Resilience to Masking: When 50% of an image's pixels are randomly masked out using Cutout, ViT L-16 retains a solid 60.4% top-1 accuracy, whereas BiT drops significantly lower to 52%.

Limitations and Future Work

  • The Contrast Blindspot: Curiously, ViT performs poorly on contrast corruptions within the ImageNet-C dataset compared to its CNN counterparts. The authors note this as an open area for future research into human-like vision performance.
Figure 2: Top-1 accuracy (%) of ViT and BiT for contrast corruption (with the high- est severity level) on ImageNet-C.
  • Background Vulnerability: On the ImageNet-9 benchmark, ViT's background robustness is worse than a standard vanilla ResNet-50. The authors hypothesize that ViT's simple patch tokenization limits its ability to process fine-grained local structures, suggesting that hybrid tokenization methods could be a promising future direction.

Summary updated

BibTeX
@inproceedings{paul2022vision,
  author = {Sayak Paul and Pin-Yu Chen},
  title = {{Vision Transformers are Robust Learners}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i2.20103},
}
Figure