[Paper Review] Three things everyone should know about Vision Transformers
This paper presents three practical improvements for Vision Transformers: (1) parallelizing residual blocks to improve training efficiency and reduce latency without accuracy loss; (2) fine-tuning only attention layers for resolution adaptation and transfer learning, saving compute and memory; and (3) introducing a hierarchical MLP stem that enables effective patch pre-processing in masked self-supervised learning, boosting performance on BeiT and supervised benchmarks.
After their initial success in natural language processing, transformer architectures have rapidly gained traction in computer vision, providing state-of-the-art results for tasks such as image classification, detection, segmentation, and video analysis. We offer three insights based on simple and easy to implement variants of vision transformers. (1) The residual layers of vision transformers, which are usually processed sequentially, can to some extent be processed efficiently in parallel without noticeably affecting the accuracy. (2) Fine-tuning the weights of the attention layers is sufficient to adapt vision transformers to a higher resolution and to other classification tasks. This saves compute, reduces the peak memory consumption at fine-tuning time, and allows sharing the majority of weights across tasks. (3) Adding MLP-based patch pre-processing layers improves Bert-like self-supervised training based on patch masking. We evaluate the impact of these design choices using the ImageNet-1k dataset, and confirm our findings on the ImageNet-v2 test set. Transfer performance is measured across six smaller datasets.
Motivation & Objective
- To explore architectural modifications that improve training efficiency and inference latency in Vision Transformers without sacrificing accuracy.
- To investigate whether fine-tuning only the attention layers is sufficient for adapting ViTs to higher resolutions or new classification tasks.
- To design a patch pre-processing stem compatible with mask-based self-supervised learning methods like BeiT, improving performance while preserving inductive bias.
- To evaluate the impact of these design choices across multiple benchmarks, including ImageNet-1k, ImageNet-v2, and transfer learning on six smaller datasets.
Proposed method
- Proposes a parallelized architecture where multi-head self-attention (MHSA) and feedforward network (FFN) blocks are reorganized into pairs, enabling wider and shallower networks with equivalent FLOPS and parameters.
- Introduces a fine-tuning strategy that freezes FFN layers and only updates attention weights during adaptation to new resolutions or downstream tasks.
- Designs a hierarchical MLP (hMLP) stem that applies multiple linear layers with non-linearities and patch aggregation, ensuring no inter-patch communication to preserve masking in self-supervised learning.
- Applies the hMLP stem before the ViT encoder, with masking applied after preprocessing, enabling compatibility with masked autoencoding methods like BeiT.
- Employs standard training protocols: 300 epochs for supervised pre-training, 100 epochs fine-tuning for transfer tasks, and uses LayerScale and standard data augmentation.
- Compares performance across multiple stem designs—linear, batch-normalized, convolutional, and hMLP—on ImageNet-1k and transfer benchmarks using consistent hyperparameters and random seeds.
Experimental results
Research questions
- RQ1Can parallelizing residual blocks in Vision Transformers improve training efficiency and inference latency without degrading accuracy?
- RQ2Is it possible to fine-tune only the attention layers of a ViT for resolution adaptation or transfer learning while maintaining competitive performance?
- RQ3Can a patch pre-processing stem be designed to be compatible with mask-based self-supervised learning (e.g., BeiT) while improving performance?
- RQ4How does the proposed hMLP stem compare to existing convolutional and linear stems in terms of accuracy, FLOPS, and generalization across supervised and self-supervised settings?
Key findings
- Parallelizing ViT blocks improves optimization and reduces latency on GPUs, especially with small batch sizes, while maintaining or slightly improving accuracy.
- Fine-tuning only the attention layers achieves comparable accuracy to full fine-tuning when adapting ViTs to higher resolutions or new classification tasks, reducing compute and memory usage.
- The hMLP stem improves top-1 accuracy by +0.38% on ImageNet-v2 and +0.39% on ImageNet-val under BeiT pre-training, outperforming both linear and convolutional stems.
- The hMLP stem achieves performance on par with the best convolutional stem (LeViT) in supervised learning while using 1.15× fewer FLOPS and avoiding inter-patch communication.
- Existing convolutional stems fail to improve performance in BeiT pre-training due to interference with masking, whereas the hMLP stem successfully leverages both patch pre-processing and masked prediction.
- The hMLP stem increases FLOPS by only 0.8% compared to ViT-B12, yet delivers significant accuracy gains in self-supervised and transfer learning settings.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.