When Vision Transformers Outperform ResNets without Pre-training or Strong Data Augmentations

Xiangning Chen, Cho-Jui Hsieh, Boqing Gong

TL;DR

Vision Transformers (ViTs) and MLP-Mixers typically require massive datasets or extreme data augmentation to compete with ResNets. This paper reveals that these models suffer from "sharp" loss landscapes that hinder generalization. By using Sharpness-Aware Minimization (SAM) to find flatter minima, ViTs can finally outperform ResNets on ImageNet from scratch using only standard preprocessing.

What Problem Does This Paper Address?

While Vision Transformers have taken the computer vision world by storm, they have a well-known "data hunger" problem. Unlike Convolutional Neural Networks (CNNs), ViTs lack inherent inductive biases like translation equivariance (the ability to recognize an object regardless of its position). To compensate, researchers usually resort to massive pre-training (e.g., on JFT-300M) or complex "stacks" of strong data augmentations like Mixup and RandAugment.

The authors of this paper ask a fundamental question: Is the weakness of ViTs an architectural flaw, or an optimization one? They investigate the "loss geometry"—the mathematical landscape the model navigates during training—to see if ViTs are simply harder to optimize than their ResNet cousins.

Methods

The researchers employ two main strategies to diagnose and fix the optimization of ViTs and MLP-Mixers:

  1. Loss Landscape Visualization & Hessian Analysis: They use "filter normalization" to visualize the loss surface and calculate the Hessian dominate eigenvalue ($\lambda_{max}$). A high $\lambda_{max}$ indicates an extremely "sharp" local minimum, which usually correlates with poor generalization to new data.
  2. Sharpness-Aware Minimization (SAM): Instead of using standard optimizers like Adam or SGD, which only look for the lowest error at a single point, the authors use SAM. SAM is a minimax optimizer: it seeks a parameter region where the loss is low not just at one point, but across an entire neighborhood. Effectively, it "smooths" the landscape during training to find flatter, more robust minima.

Crucially, they test this using only basic Inception-style preprocessing, stripping away the "strong" augmentations that usually mask these optimization issues.

Datasets

The study evaluates models across a wide range of standard benchmarks:

  • Training: ImageNet-1k (standard) and ImageNet-21k (large-scale).
  • Robustness: ImageNet-C (corruptions like blur/noise), ImageNet-R (renditions like art/cartoons), ImageNet-V2, and ImageNet-ReaL.
  • Transfer Learning: CIFAR-10, CIFAR-100, Oxford-IIIT Pets, and Oxford Flowers-102.

Key Insights and Ideas

  • ViTs are "Sharper" than ResNets: The authors found that ViTs and MLP-Mixers converge to local minima that are nearly an order of magnitude sharper than those of ResNets. This explains why they often "overfit" even when training error is near zero.
Loss landscapes of various architectures
  • The Sparsity Connection: One of the most surprising findings is that SAM-trained models develop sparser active neurons in their early layers. This suggests that finding a flat minimum naturally encourages the model to focus on the most important features, effectively performing a type of internal "pruning."
  • Optimization as Inductive Bias: The results suggest that a better optimizer can act as a substitute for the hand-wired inductive biases of CNNs. By forcing the model to find flat regions, SAM helps ViTs learn more generalizable representations without needing the "hint" of a convolution.
  • Improved Attention Maps: Qualitatively, ViTs trained with SAM show much cleaner, more interpretable attention maps that focus better on the actual objects in an image compared to vanilla training.

Key Results

  • Accuracy Boost: On ImageNet-1k, SAM improved ViT-B/16 top-1 accuracy from 74.6% to 79.9% (+5.3%) and Mixer-B/16 from 66.4% to 77.4% (+11.0%).
  • Beating ResNets: With SAM, ViT-B/16 (79.9%) outperformed a similarly sized ResNet-152 (79.3%) without any of the usual "strong" data augmentation tricks.
  • Superior Robustness: SAM-trained ViTs showed massive gains in robustness. On ImageNet-C, ViT-B/16 accuracy jumped from 46.6% to 56.5%.
  • Transferability: Models trained with SAM on ImageNet transferred significantly better to smaller downstream datasets like CIFAR and Flowers, proving that the learned features are more universal.

Limitations and Future Work

  • Computational Overhead: The primary drawback of SAM is that it requires two forward and backward passes per training step, effectively doubling the training time compared to standard Adam or SGD.
  • Diminishing Returns with Scale: The authors noted that as the training dataset gets significantly larger (e.g., ImageNet-21k), the performance gap between SAM and vanilla optimizers begins to shrink.
  • Future Direction: The authors suggest a need for more efficient "sharpness-aware" algorithms that can provide these generalization benefits without the 2x computational cost. There is also room to explore how these findings apply to other modalities like video or audio transformers.

Summary updated

BibTeX
@inproceedings{chen2022when,
  author = {Xiangning Chen and Cho-Jui Hsieh and Boqing Gong},
  title = {{When Vision Transformers Outperform ResNets without Pre-training or Strong Data Augmentations}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=LtKcMgGOeLt},
}
Figure