TL;DR
Vision Transformers (ViTs) struggle to benefit from increased depth, unlike CNNs, due to an "attention collapse" where attention maps become too similar in deeper layers. This paper introduces "Re-attention," a simple mechanism that encourages attention map diversity, enabling deeper ViTs to achieve consistent performance gains, including a 1.6% improvement on ImageNet with a 32-block model.
What Problem Does This Paper Address?
Convolutional Neural Networks (CNNs) have historically benefited greatly from increasing their depth, leading to richer feature representations and improved performance on vision tasks. This has led researchers to wonder if the same scaling principle applies to the newer Vision Transformer (ViT) architecture. However, initial experiments with ViTs show that simply stacking more transformer blocks doesn't lead to continuous performance improvements; performance saturates and can even degrade. This paper investigates why this happens and proposes a solution. The core problem is identified as "attention collapse," where the self-attention mechanism in deeper ViT layers produces increasingly similar attention maps, hindering the learning of diverse and effective representations.
Methods
The paper's main contribution is the Re-attention mechanism. It addresses the attention collapse by introducing a way to regenerate attention maps within each transformer block. Instead of directly using the attention maps generated by the standard multi-head self-attention (MHSA), Re-attention leverages the inherent diversity across different attention heads. It learns a transformation matrix that mixes the attention maps from these heads, creating new, more diverse attention maps. This process is computationally inexpensive and requires only minor modifications to the existing ViT architecture. The authors also explore increasing the embedding dimension as an alternative, but find it less efficient due to increased computational cost and diminishing returns.
Datasets
The primary dataset used for training and evaluation in this paper is ImageNet. The authors report results on ImageNet-1k.
Key Insights and Ideas
- Attention Collapse is Real: The paper provides strong empirical evidence that ViTs suffer from "attention collapse," where attention maps become nearly identical in deeper layers, preventing further performance gains from increased depth. This is a critical finding that challenges the direct transfer of CNN scaling strategies to ViTs.
- Self-Attention is the Bottleneck: Unlike CNNs where depth scaling is well-understood, the self-attention mechanism in ViTs is identified as the key component that limits depth scaling.
- Head Diversity is Key: The paper highlights that while attention maps across layers become similar, different attention heads within a layer still exhibit diversity. Re-attention capitalizes on this by mixing information across heads.
- Simple Fix, Big Impact: The proposed Re-attention mechanism is remarkably simple, involving a learnable transformation matrix. Despite its simplicity, it effectively combats attention collapse and leads to significant performance improvements in deeper ViTs.
- Deeper ViTs are Viable: The work demonstrates that it's possible to train much deeper ViTs (up to 32 blocks) effectively, achieving state-of-the-art results without requiring extensive data augmentation or pre-training on massive datasets.
Key Results
- Performance Saturation: Standard ViTs with 12, 16, 24, and 32 transformer blocks show performance saturation on ImageNet, with the 32-block model performing worse than the 24-block model.
- Re-attention Improvement: By replacing the standard self-attention with Re-attention, the authors achieve consistent performance improvements as depth increases.
- DeepViT-32B Gains: A 32-block ViT model (DeepViT-32B) trained with Re-attention achieved a 1.6% improvement in Top-1 accuracy on ImageNet compared to the baseline ViT-32B.
- Efficiency: Re-attention adds negligible computational overhead and memory cost compared to the original self-attention.
- State-of-the-Art: The proposed DeepViT models (DeepViT-S and DeepViT-L) achieve competitive or superior accuracy compared to other SOTA CNN and ViT models, often with fewer parameters and without relying on complex training recipes or large pre-training datasets. For instance, DeepViT-L outperforms existing models by 0.4 points with a smaller model size.
Limitations and Future Work
- Attention Collapse Mitigation: While Re-attention effectively mitigates attention collapse, the paper notes that even with Re-attention, the very last block might still learn a nearly uniform attention map.
- Hyperparameter Tuning: The paper mentions that improved training recipes (like those used in DeiT) can further boost DeepViT performance, suggesting that optimal training strategies are still an area for exploration.
- Future Directions: The authors hope their findings and methods will facilitate the development of deeper and more powerful vision transformers in the future. They suggest that understanding and addressing the attention collapse is crucial for unlocking the full potential of ViTs.
Summary updated