Improve Vision Transformers Training by Suppressing Over-smoothing

Chengyue Gong, Dilin Wang, Meng Li, Vikas Chandra, Qiang Liu

Abstract

Vision Transformers (ViTs) have demonstrated promising performance on challenging computer vision tasks. However, directly training deep ViTs can yield unstable and sub-optimal results. We observe that this instability is often attributable to "over-smoothing," where self-attention blocks map different patches into highly similar latent representations, leading to information loss. To alleviate this, we introduce DiversePatch, a set of novel loss functions that explicitly encourage diversity across patch representations. Our techniques stabilize training, enable deeper architectures, and achieve state-of-the-art results on ImageNet, Cityscapes, and ADE20k.

The Over-smoothing Problem

In a Vision Transformer, an image is processed as a sequence of patches. Through successive self-attention layers, these patches share information to build a global representation. However, in deep models like a 24-layer DeiT, this process can lead to representation collapse.

Cosine similarity of patch representations across blocks. Deep ViTs like DeiT-Base24 show significant over-smoothing compared to ResNet-50.

As illustrated above, the cosine similarity between patch representations in deep ViTs increases significantly with depth, often exceeding 0.7. This indicates that patches lose their unique spatial identities and become nearly identical, a phenomenon not observed in traditional CNNs like ResNet-50. This over-smoothing limits the benefits of adding more layers, as deeper blocks primarily contribute to further information loss rather than feature refinement.

Methodology: DiversePatch

To combat over-smoothing without modifying the network architecture, we propose three auxiliary training objectives that promote feature diversity:

  1. Patch-wise Cosine Loss: This loss directly minimizes the cosine similarity between all pairs of patch representations in the final layer, forcing the model to maintain distinct features for different spatial regions.
  2. Patch-wise Contrastive Loss: This approach encourages a patch in the final layer to remain similar to its own representation in the first layer while pushing it away from other patches in the same image.
The Patch-wise Contrastive Loss encourages final-layer patches to retain their unique identity relative to the first layer.
  1. Patch-wise Mixing Loss: Inspired by CutMix, we mix patches from two different images and use an auxiliary classification head to force each final-layer patch to predict its original category. This ensures that each patch retains discriminative, class-specific information.

These losses are discarded after training, ensuring that the final model retains the standard ViT architecture and inference efficiency.

Key Results and Discussion

The researchers evaluated DiversePatch across several major benchmarks, demonstrating its effectiveness in stabilizing and improving deep ViTs:

  • ImageNet-1K: DiversePatch boosted the top-1 accuracy of a 24-layer DeiT-Small from 80.3% to 82.2%. It also enabled the Swin-Large model to reach a top-1 accuracy of 87.4%.
  • Semantic Segmentation: The diversified features proved exceptionally potent for dense tasks. Using these models as backbones, the authors set new state-of-the-art records, achieving 83.6 mIoU on Cityscapes and 54.5 mIoU on ADE20k.
  • Architecture vs. Objective: While other works attempt to fix ViTs by adding convolutional layers, this research proves that the over-smoothing problem can be addressed purely through improved training objectives.

Conclusion

By identifying and suppressing over-smoothing, the DiversePatch framework allows for the successful training of wider and deeper Vision Transformers. The resulting diversified features not only improve classification performance but also provide significant advantages for downstream transfer learning tasks like semantic segmentation.

Summary updated

BibTeX
@misc{gong2021improve,
  author = {Chengyue Gong and Dilin Wang and Meng Li and Vikas Chandra and Qiang Liu},
  title = {{Improve Vision Transformers Training by Suppressing Over-smoothing}},
  year = {2021},
  eprint = {2104.12753},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.12753},
}
Figure