ResMLP: Feedforward Networks for Image Classification With Data-Efficient Training

Hugo Touvron, Piotr Bojanowski, Mathilde Caron, Matthieu Cord, Alaaeldin El-Nouby, Edouard Grave, Gautier Izacard, Armand Joulin, Gabriel Synnaeve, Jakob Verbeek, Hervé Jégou · DOI

TL;DR

This paper introduces ResMLP, a novel image classification architecture composed entirely of multi-layer perceptrons (MLPs). By replacing the self-attention mechanism of Vision Transformers with simple linear layers for patch interaction, ResMLP achieves competitive accuracy on ImageNet with improved efficiency and training stability, demonstrating the potential of pure MLP architectures for computer vision tasks.

What Problem Does This Paper Address?

The paper addresses the ongoing trend in computer vision to reduce architectural priors, moving away from hand-designed features towards more flexible, data-driven learning. While Convolutional Neural Networks (CNNs) introduced trainable feature extractors, and Vision Transformers (ViTs) further reduced inductive biases by removing local connectivity and translation invariance, the authors explore the extreme of removing all architectural priors. Specifically, they question the necessity of self-attention in ViTs and investigate whether a purely MLP-based architecture can achieve competitive performance in image classification, especially when trained with modern, data-efficient strategies.

Methods

The core innovation is the ResMLP architecture, a residual network built exclusively from MLPs. It processes images by first dividing them into patches and linearly projecting them into embeddings. The network then alternates between two types of residual blocks:

  1. Cross-patch sublayer: A linear layer that allows image patches to interact across all channels simultaneously. This replaces the self-attention mechanism in Transformers.
  2. Cross-channel sublayer: A two-layer feed-forward network (MLP) that processes channels independently for each patch.

Key simplifications and design choices include:

  • No self-attention: Replaced by a linear layer.
  • No positional embeddings: The linear layer implicitly handles positional information.
  • No "class" token: Average pooling is used to aggregate patch embeddings.
  • No batch/channel statistics: Replaced by a learnable affine transformation (Aff) for normalization, which is computationally cheaper at inference.

The authors also explore training ResMLP with modern techniques like heavy data-augmentation, knowledge distillation (from CNNs), and self-supervised learning (DINO).

Datasets

  • ImageNet-1k: Used for training and evaluating the primary image classification models. Performance is reported on the validation set.
  • ImageNet-real and ImageNet-v2: Used for additional evaluation to assess generalization and potential overfitting.
  • ImageNet-21k: Used for pre-training larger ResMLP models.
  • WMT 2014 English-German and English-French: Used for evaluating the ResMLP architecture adapted for machine translation.

Key Insights and Ideas

  • MLPs can be competitive: Purely MLP-based architectures, when trained with modern strategies, can achieve surprisingly good accuracy on large-scale image classification tasks like ImageNet, challenging the perceived necessity of convolutional or attention-based inductive biases.
  • Simplicity aids stability: Replacing self-attention with linear layers leads to more stable training, removing the need for complex normalization layers like LayerNorm.
  • Linear interactions can resemble convolutions: Visualizations of the cross-patch linear layers reveal patterns similar to convolutional filters in early layers, suggesting a potential link between these simple linear interactions and learned spatial features.
  • Data-efficiency is crucial: ResMLP benefits significantly from advanced training techniques like heavy data-augmentation and knowledge distillation, highlighting the importance of the training regime over architectural priors.
  • Generalization without priors: The architecture demonstrates competitive performance in transfer learning tasks, suggesting that sufficient data and regularization can mitigate the lack of explicit architectural priors.

Key Results

  • ImageNet Performance: ResMLP models achieve competitive accuracy/complexity trade-offs on ImageNet-1k. For instance, ResMLP-B24 achieves 81.0% top-1 accuracy with 23B FLOPs, comparable to some Transformer models.
  • Training Stability: ResMLP training is more stable than ViTs when using similar training schemes.
  • Self-supervised Learning: ResMLP performs competitively with CNNs and ViTs in k-NN evaluation after self-supervised pre-training with DINO.
  • Knowledge Distillation: Distillation significantly improves ResMLP performance, similar to its effect on ViTs.
  • Machine Translation: A seq2seq ResMLP architecture achieves competitive results on WMT 2014 translation tasks, comparable to Transformer baselines.
  • Ablation Studies: Removing self-attention leads to a significant drop in accuracy (-20%), confirming its importance. Replacing average pooling with a "Class-MLP" improves performance. Using smaller patches generally increases performance but requires more regularization.

Limitations and Future Work

  • Overfitting: While generally comparable to other architectures, ResMLPs can still overfit, though this is mitigated by regularization techniques like distillation.
  • Accuracy vs. Efficiency Trade-off: While competitive, ResMLP's accuracy/FLOPs/throughput trade-off is not as strong as some convolutional networks or Transformers when trained on ImageNet alone.
  • Future Work: The authors suggest further research into network compression (pruning, quantization) due to the observed sparsity in linear layers. They also propose exploring convolutional variants of the patch interaction layer, as visualizations suggest similarities. The potential of ResMLP for tasks beyond image classification, like machine translation, is also highlighted.

Summary updated

BibTeX
@article{touvron2021resmlp,
  author = {Hugo Touvron and Piotr Bojanowski and Mathilde Caron and Matthieu Cord and Alaaeldin El-Nouby and Edouard Grave and Gautier Izacard and Armand Joulin and Gabriel Synnaeve and Jakob Verbeek and Hervé Jégou},
  title = {{ResMLP: Feedforward Networks for Image Classification With Data-Efficient Training}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2021},
  doi = {10.1109/tpami.2022.3206148},
}
Figure