Stand-Alone Self-Attention in Vision Models

Prajit Ramachandran, Niki Parmar, Ashish Vaswani, Irwan Bello, Anselm Levskaya +1 more
6/13/2019
cs.CV

Official code: google-research/google-research (39,000 stars, Apache-2.0, last commit 2026-04-30).

Abstract

Convolutions are a fundamental building block of modern computer vision systems. Recent approaches have argued for going beyond convolutions in order to capture long-range dependencies. These efforts focus on augmenting convolutional models with content-based interactions, such as self-attention and non-local means, to achieve gains on a number of vision tasks. The natural question that arises is whether attention can be a stand-alone primitive for vision models instead of serving as just an augmentation on top of convolutions. In developing and testing a pure self-attention vision model, we verify that self-attention can indeed be an effective stand-alone layer. A simple procedure of replacing all instances of spatial convolutions with a form of self-attention applied to ResNet model produces a fully self-attentional model that outperforms the baseline on ImageNet classification with 12% fewer FLOPS and 29% fewer parameters. On COCO object detection, a pure self-attention model matches the mAP of a baseline RetinaNet while having 39% fewer FLOPS and 34% fewer parameters. Detailed ablation studies demonstrate that self-attention is especially impactful when used in later layers. These results establish that stand-alone self-attention is an important addition to the vision practitioner's toolbox.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Google Research

39,0008,488C, ROct 4, 20185 months agoApache-2.0
aimachine-learningresearch

Similar Papers

Cite this paper

@article{ramachandran2019standalone,
  title  = {Stand-Alone Self-Attention in Vision Models},
  author = {Prajit Ramachandran and Niki Parmar and Ashish Vaswani and Irwan Bello and Anselm Levskaya and Jonathon Shlens},
  year   = {2019},
  eprint = {1906.05909},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1906.05909}
}

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/1906.05909.svg)](https://codeofpaper.com/paper/1906.05909)

Discussion