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

Chuanxin Tang, Yucheng Zhao, Guangting Wang, Chong Luo, Wenxuan Xie, Wenjun Zeng

Abstract

Vision Transformers (ViTs) have recently surpassed Convolutional Neural Networks (CNNs) in image recognition, with self-attention often cited as the key differentiator. However, self-attention is computationally intensive and lacks inductive biases like locality. We present sMLPNet, which utilizes a Sparse MLP (sMLP) module to mix information along axial dimensions. sMLPNet matches the accuracy of the Swin Transformer on ImageNet-1K while significantly reducing parameter counts and improving efficiency.

Introduction

The rise of Vision Transformers (ViTs) has shifted the focus of image recognition research toward self-attention mechanisms. While effective, self-attention suffers from quadratic computational complexity and ignores the spatial locality inherent in images. Previous attempts to use Multi-Layer Perceptrons (MLPs) as a simpler alternative, such as MLP-Mixer, often required massive datasets to avoid overfitting. sMLPNet addresses these issues by creating an efficient, attention-free network that respects image structure through axial mixing and locality injection.

Methods and Architecture

sMLPNet adopts a pyramid structure similar to modern CNNs and the Swin Transformer, processing images in four stages with decreasing spatial resolution and increasing channel depth.

The overall sMLPNet architecture (a) and the internal token mixing block (b) featuring depth-wise convolutions and the sMLP module.

The core of the architecture is the Token Mixing block, which combines locality and global dependency modeling:

  1. Locality Injection: Depth-wise Convolutions (DWConv) are used to capture local patterns like edges and textures.
  2. The sMLP Module: This module replaces dense MLPs with a sparse alternative that decomposes spatial mixing into parallel branches.

The Sparse MLP (sMLP) Module

The sMLP module avoids the parameter explosion of dense MLPs by mixing information along the horizontal and vertical axes independently.

Detailed structure of the sMLP module, showing parallel horizontal and vertical mixing branches alongside an identity mapping.

As shown in the figure above, the module consists of three parallel paths:

  • Horizontal Mixing: A 1D MLP mixes information across rows.
  • Vertical Mixing: A 1D MLP mixes information across columns.
  • Identity Mapping: A shortcut preserves original features to facilitate gradient flow. Weights are shared across rows and columns, reducing the parameter count in the mixing layer by approximately 3,000x compared to a standard dense MLP.

Key Insights

  • Sparsity vs. Density: Axial (1D) MLPs provide a powerful regularization effect, preventing the model from memorizing noise and allowing it to train effectively on standard datasets like ImageNet-1K.
  • Weight Sharing as Inductive Bias: By sharing weights across spatial dimensions, the model learns general spatial transformations rather than specific pixel-to-pixel mappings.
  • Global Dependencies without Attention: sMLPNet demonstrates that the primary benefit of self-attention may be its ability to model global dependencies, which can be achieved more efficiently with static, learned weights in an axial MLP.

Experimental Results

The model was evaluated on the ImageNet-1K dataset (1.2M images). Unlike earlier MLP models, sMLPNet does not require massive pre-training on private datasets.

  • sMLPNet-T (Tiny): Achieved 81.9% top-1 accuracy with 24M parameters, outperforming Swin-T (81.3% with 29M parameters).
  • sMLPNet-B (Base): Reached 83.4% accuracy with 66M parameters, matching the performance of the larger Swin-B (88M parameters).
  • Efficiency: sMLPNet maintains stability on medium-scale datasets where previous MLP-based architectures typically struggled.

Conclusion and Future Work

sMLPNet proves that self-attention is not strictly necessary for state-of-the-art image recognition. By leveraging axial sparsity and locality injection, the model achieves high efficiency and accuracy. Future work includes extending this architecture to downstream tasks such as object detection and semantic segmentation, where the efficiency of sMLP at higher resolutions could provide even greater advantages.

Summary updated

BibTeX
@inproceedings{tang2022sparse,
  author = {Chuanxin Tang and Yucheng Zhao and Guangting Wang and Chong Luo and Wenxuan Xie and Wenjun Zeng},
  title = {{Sparse MLP for Image Recognition: Is Self-Attention Really Necessary?}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i2.20133},
}
Figure