On the Integration of Self-Attention and Convolution
Xuran Pan, Chunjiang Ge, Rui Lu, Shiji Song, Guanfu Chen, Zeyi Huang, Gao Huang
Abstract
Convolution and self-attention are two powerful techniques for representation learning, and they are usually considered as two peer approaches that are distinct from each other. In this paper, we show that there exists a strong underlying relation between them, in the sense that the bulk of computations of these two paradigms are in fact done with the same operation. Specifically, we first show that a traditional convolution with kernel size k × k can be decomposed into k <sup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">2</sup> individual 1 × 1 convolutions, followed by shift and summation operations. Then, we interpret the projections of queries, keys, and values in self-attention module as multiple 1 × 1 convolutions, followed by the computation of attention weights and aggregation of the values. Therefore, the first stage of both two modules comprises the similar operation. More importantly, the first stage contributes a dominant computation complexity (square of the channel size) comparing to the second stage. This observation naturally leads to an elegant integration of these two seemingly distinct paradigms, i.e., a mixed model that enjoys the benefit of both self-Attention and Convolution (ACmix), while having minimum compu-tational overhead compared to the pure convolution or self-attention counterpart. Extensive experiments show that our model achieves consistently improved results over com-petitive baselines on image recognition and downstream tasks. Code and pre-trained models will be released at https://github.com/LeapLabTHU/ACmix and https://gitee.com/mindspore/models.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
24 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions cites Training data-efficient image transformers & distillation through attention
- FLatten Transformer: Vision Transformer using Focused Linear Attention cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- FLatten Transformer: Vision Transformer using Focused Linear Attention cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- FLatten Transformer: Vision Transformer using Focused Linear Attention cites Training data-efficient image transformers & distillation through attention
- FLatten Transformer: Vision Transformer using Focused Linear Attention cites Vision Transformer with Deformable Attention
- FLatten Transformer: Vision Transformer using Focused Linear Attention cites Deformable DETR: Deformable Transformers for End-to-End Object Detection
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale cites Language Models are Few-Shot Learners
- Multi-Scale VMamba: Hierarchy in Hierarchy Visual State Space Model cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Multi-Scale VMamba: Hierarchy in Hierarchy Visual State Space Model cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Multi-Scale VMamba: Hierarchy in Hierarchy Visual State Space Model cites Training data-efficient image transformers & distillation through attention
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites Training data-efficient image transformers & distillation through attention
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows cites Deformable DETR: Deformable Transformers for End-to-End Object Detection
- Training data-efficient image transformers & distillation through attention cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Vision Transformer with Deformable Attention cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Vision Transformer with Deformable Attention cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Vision Transformer with Deformable Attention cites Training data-efficient image transformers & distillation through attention
- Vision Transformer with Deformable Attention cites Deformable DETR: Deformable Transformers for End-to-End Object Detection
- SeaFormer: Squeeze-enhanced Axial Transformer for Mobile Semantic Segmentation cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- SeaFormer: Squeeze-enhanced Axial Transformer for Mobile Semantic Segmentation cites Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
Cited by top-tier papers24
- Vision Transformer with Deformable AttentionZhuofan Xia, Xuran Pan, Shiji Song, Li Erran Li et al.CVPR 2022 · 835 citations
- HorNet: Efficient High-Order Spatial Interactions with Recursive Gated ConvolutionsYongming Rao, Wenliang Zhao, Yansong Tang, Jie Zhou et al.NeurIPS 2022 · 422 citations
- FLatten Transformer: Vision Transformer using Focused Linear AttentionDongchen Han, Xuran Pan, Yizeng Han, Shiji Song et al.ICCV 2023 · 358 citations
- Multi-Scale VMamba: Hierarchy in Hierarchy Visual State Space ModelYuheng Shi, Minjing Dong, Chang XuNeurIPS 2024 · 129 citations
- SeaFormer: Squeeze-enhanced Axial Transformer for Mobile Semantic SegmentationQiang Wan, Zilong Huang, Jiachen Lu, Gang Yu et al.ICLR 2023 · 82 citations
Builds on21
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- Training data-efficient image transformers & distillation through attentionHugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa et al.ICML 2021 · 8,974 citations
- Deformable DETR: Deformable Transformers for End-to-End Object DetectionXizhou Zhu, Weijie Su, Lewei Lu, Bin Li et al.ICLR 2021 · 7,353 citations
Related papers
- Revisiting the Integration of Convolution and Attention for Vision BackboneLei Zhu, Xinjiang Wang, Wayne Zhang, Rynson W. H. LauNeurIPS 2024 · 9 citations
- MOAT: Alternating Mobile Convolution and Attention Brings Strong Vision ModelsChenglin Yang, Siyuan Qiao, Qihang Yu, Xiaoding Yuan et al.ICLR 2023 · 22 citations
- On the Relationship between Self-Attention and Convolutional LayersJean-Baptiste Cordonnier, Andreas Loukas, Martin JaggiICLR 2020 · 629 citations
- MixFormer: Mixing Features across Windows and DimensionsQiang Chen, Qiman Wu, Jian Wang, Qinghao Hu et al.CVPR 2022 · 142 citations
- Attention Augmented Convolutional NetworksIrwan Bello, Barret Zoph, Quoc Le, Ashish Vaswani et al.ICCV 2019 · 1,149 citations
