Sparse MLP for Image Recognition: Is Self-Attention Really Necessary?

Chuanxin Tang, Yucheng Zhao, Guangting Wang, Chong Luo, Wenxuan Xie +1 more
9/12/2021
130 citations
cs.CV
transformer-attention

Official code: microsoft/SPACH (204 stars, Python, MIT, last commit 2024-07-25).

Abstract

Transformers have sprung up in the field of computer vision. In this work, we explore whether the core self-attention module in Transformer is the key to achieving excellent performance in image recognition.

Show full abstract

To this end, we build an attention-free network called sMLPNet based on the existing MLP-based vision models. Specifically, we replace the MLP module in the token-mixing step with a novel sparse MLP (sMLP) module. For 2D image tokens, sMLP applies 1D MLP along the axial directions and the parameters are shared among rows or columns. By sparse connection and weight sharing, sMLP module significantly reduces the number of model parameters and computational complexity, avoiding the common over-fitting problem that plagues the performance of MLP-like models. When only trained on the ImageNet-1K dataset, the proposed sMLPNet achieves 81.9% top-1 accuracy with only 24M parameters, which is much better than most CNNs and vision Transformers under the same model size constraint. When scaling up to 66M parameters, sMLPNet achieves 83.4% top-1 accuracy, which is on par with the state-of-the-art Swin Transformer. The success of sMLPNet suggests that the self-attention mechanism is not necessarily a silver bullet in computer vision. The code and models are publicly available at https://github.com/microsoft/SPACH

View on arXivView PDF

Code Implementations(1)

microsoft/SPACHOfficial100%
MIT
20427PythonOct 26, 20212 years agoMIT

Similar Papers

Cite this paper

@article{tang2021sparse,
  title  = {Sparse MLP for Image Recognition: Is Self-Attention Really Necessary?},
  author = {Chuanxin Tang and Yucheng Zhao and Guangting Wang and Chong Luo and Wenxuan Xie and Wenjun Zeng},
  year   = {2021},
  eprint = {2109.05422},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2109.05422}
}

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

Discussion