Twins: Revisiting the Design of Spatial Attention in Vision Transformers
Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing, Ren, Xiaolin Wei, Huaxia Xia, Chunhua Shen

TL;DR
This paper introduces simple yet effective spatial attention mechanisms in vision transformers, resulting in two architectures that outperform existing models across various visual tasks with high efficiency.
Contribution
The paper proposes two novel vision transformer architectures, Twins-PCPVT and Twins-SVT, featuring a straightforward spatial attention design that enhances performance and efficiency.
Findings
Achieved state-of-the-art results on multiple visual tasks
Demonstrated high efficiency and ease of implementation
Provided open-source code for reproducibility
Abstract
Very recently, a variety of vision transformer architectures for dense prediction tasks have been proposed and they show that the design of spatial attention is critical to their success in these tasks. In this work, we revisit the design of the spatial attention and demonstrate that a carefully-devised yet simple spatial attention mechanism performs favourably against the state-of-the-art schemes. As a result, we propose two vision transformer architectures, namely, Twins-PCPVT and Twins-SVT. Our proposed architectures are highly-efficient and easy to implement, only involving matrix multiplications that are highly optimized in modern deep learning frameworks. More importantly, the proposed architectures achieve excellent performance on a wide range of visual tasks, including image level classification as well as dense detection and segmentation. The simplicity and strong performance…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
- 🤗kadirnar/timm_model_listmodel· ♡ 1♡ 1
- 🤗timm/twins_pcpvt_base.in1kmodel· 1.4k dl· ♡ 11.4k dl♡ 1
- 🤗timm/twins_pcpvt_large.in1kmodel· 234 dl234 dl
- 🤗timm/twins_pcpvt_small.in1kmodel· 239 dl239 dl
- 🤗timm/twins_svt_base.in1kmodel· 695 dl· ♡ 1695 dl♡ 1
- 🤗timm/twins_svt_large.in1kmodel· 59k dl59k dl
- 🤗timm/twins_svt_small.in1kmodel· 674 dl674 dl
Videos
Taxonomy
Topics3D Surveying and Cultural Heritage · Visual Attention and Saliency Detection · CCD and CMOS Imaging Sensors
MethodsAttention Is All You Need · Linear Layer · Depthwise Convolution · Positional Encoding Generator · Conditional Positional Encoding · Global Sub-Sampled Attention · Locally-Grouped Self-Attention · Spatially Separable Self-Attention · Twins-SVT · Twins-PCPVT
