How to train your ViT? Data, Augmentation, and Regularization in Vision Transformers

Andreas Steiner, Alexander Kolesnikov, Xiaohua Zhai, Ross Wightman, Jakob Uszkoreit +1 more
6/18/2021
934 citations
cs.CVcs.AIcs.LG
transformer-attention

Official code: huggingface/pytorch-image-models (37,303 stars, Python, Apache-2.0, PyTorch, last commit 2026-04-29). 2 more implementations below.

Abstract

Vision Transformers (ViT) have been shown to attain highly competitive performance for a wide range of vision applications, such as image classification, object detection and semantic image segmentation. In comparison to convolutional neural networks, the Vision Transformer's weaker inductive bias is generally found to cause an increased reliance on model regularization or data augmentation ("AugReg" for short) when training on smaller training datasets.

Show full abstract

We conduct a systematic empirical study in order to better understand the interplay between the amount of training data, AugReg, model size and compute budget. As one result of this study we find that the combination of increased compute and AugReg can yield models with the same performance as models trained on an order of magnitude more training data: we train ViT models of various sizes on the public ImageNet-21k dataset which either match or outperform their counterparts trained on the larger, but not publicly available JFT-300M dataset.

View on arXivView PDF

Code Implementations(3)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
huggingface/pytorch-image-modelsOfficial37,303PythonApache-2.02026-04-29
google-research/vision_transformerOfficial12,778Jupyter NotebookApache-2.02026-10-01
google-research/big_visionOfficial3,577Jupyter NotebookApache-2.02025-05-19
PyTorchApache-2.0

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more

37,3035,234Python, MDXFeb 2, 20197 months agoApache-2.0
augmixconvnextdistributed-trainingefficientnetimage-classification+15 more
Apache-2.0
12,7781,481Jupyter Notebook, PythonOct 21, 20202 months agoApache-2.0
Apache-2.0

Official codebase used to develop Vision Transformer, SigLIP, MLP-Mixer, LiT and more.

3,577236Jupyter Notebook, PythonApr 4, 20221 years agoApache-2.0

Similar Papers

Cite this paper

@article{steiner2021train,
  title  = {How to train your ViT? Data, Augmentation, and Regularization in Vision Transformers},
  author = {Andreas Steiner and Alexander Kolesnikov and Xiaohua Zhai and Ross Wightman and Jakob Uszkoreit and Lucas Beyer},
  year   = {2021},
  eprint = {2106.10270},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2106.10270}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2106.10270.svg)](https://codeofpaper.com/paper/2106.10270)

Discussion