Skip to main content
QUICK REVIEW

[Paper Review] On the Integration of Self-Attention and Convolution

Xuran Pan, Chunjiang Ge|arXiv (Cornell University)|Nov 29, 2021
Domain Adaptation and Few-Shot LearningComputer Science35 references9 citations
TL;DR

This paper proposes ACmix, a novel neural network module that seamlessly integrates self-attention and convolution by sharing the same 1×1 convolution operations as the core computation, enabling efficient joint feature learning. The method achieves state-of-the-art performance on image recognition and object detection benchmarks with minimal computational overhead compared to pure self-attention or convolutional models.

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 x k can be decomposed into k^2 individual 1x1 convolutions, followed by shift and summation operations. Then, we interpret the projections of queries, keys, and values in self-attention module as multiple 1x1 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 computational overhead compared to the pure convolution or self-attention counterpart. Extensive experiments show that our model achieves consistently improved results over competitive 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.

Motivation & Objective

  • To uncover a fundamental computational similarity between self-attention and convolution that has been overlooked in prior work.
  • To design a hybrid neural module that leverages the strengths of both self-attention and convolution without doubling computational cost.
  • To reduce the inference and training overhead typically associated with combining attention and convolution modules.
  • To empirically validate that the proposed ACmix module outperforms pure convolutional or self-attention models across multiple vision benchmarks.

Proposed method

  • Decompose standard k×k convolutions into k² individual 1×1 convolutions followed by shift and summation operations.
  • Reinterpret the query, key, and value projections in self-attention as multiple 1×1 convolutions, followed by dynamic attention weight computation and value aggregation.
  • Share the same 1×1 convolutional projections across both the self-attention and convolution paths in ACmix, eliminating redundant computation.
  • Use learnable scaling parameters α and β to dynamically combine outputs from the self-attention and convolution paths, enabling adaptive routing of features.
  • Implement shift operations via group convolution or learnable kernels to maintain efficiency and flexibility in the aggregation stage.
  • Train the model with end-to-end optimization, where the shared 1×1 convolutions and learnable α, β parameters are jointly updated.

Experimental results

Research questions

  • RQ1Is there a fundamental computational equivalence between self-attention and convolution when decomposed into their primitive operations?
  • RQ2Can the shared 1×1 convolution operation serve as a unified backbone for both attention and convolution modules?
  • RQ3Does a hybrid module that reuses the same feature projections achieve better performance and efficiency than separate attention and convolution modules?
  • RQ4How do the relative contributions of self-attention and convolution evolve across different network depths?

Key findings

  • ACmix achieves a top-1 accuracy of 81.9% on ImageNet-1K, surpassing both Swin-T (81.5%) and Conv-Swin-T (81.4%) on the same setup.
  • The ablation study shows that using learnable parameters α and β for combining paths yields better performance than fixed ratios or single-path models.
  • The model with group convolution-based shift modules achieves 419 FPS on a single RTX 2080Ti GPU, demonstrating high inference efficiency.
  • Visualization of learned α and β parameters reveals a stable preference: convolution dominates in early layers, while self-attention becomes more influential in deeper layers.
  • The combination of both paths consistently outperforms models using only one module across all evaluated benchmarks and settings.
  • The proposed method reduces computational overhead compared to training separate attention and convolution modules, while maintaining or improving performance.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.