Skip to main content
QUICK REVIEW

[Paper Review] Do You Even Need Attention? A Stack of Feed-Forward Layers Does Surprisingly Well on ImageNet

Luke Melas-Kyriazi|arXiv (Cornell University)|May 6, 2021
Advanced Neural Network ApplicationsComputer Science11 references80 citations
TL;DR

The paper replaces attention in Vision Transformers with feed-forward layers over the patch dimension and finds that a FF-only model can achieve strong ImageNet top-1 accuracy, suggesting attention may not be essential for competitive performance.

ABSTRACT

The strong performance of vision transformers on image classification and other vision tasks is often attributed to the design of their multi-head attention layers. However, the extent to which attention is responsible for this strong performance remains unclear. In this short report, we ask: is the attention layer even necessary? Specifically, we replace the attention layer in a vision transformer with a feed-forward layer applied over the patch dimension. The resulting architecture is simply a series of feed-forward layers applied over the patch and feature dimensions in an alternating fashion. In experiments on ImageNet, this architecture performs surprisingly well: a ViT/DeiT-base-sized model obtains 74.9\% top-1 accuracy, compared to 77.9\% and 79.9\% for ViT and DeiT respectively. These results indicate that aspects of vision transformers other than attention, such as the patch embedding, may be more responsible for their strong performance than previously thought. We hope these results prompt the community to spend more time trying to understand why our current models are as effective as they are.

Motivation & Objective

  • Investigate whether attention is essential for Vision Transformer performance on ImageNet.
  • Assess how a feed-forward-only architecture compares to ViT/DeiT with attention.
  • Understand what components contribute most to the strong performance of vision transformers.

Proposed method

  • Replace the attention layer in ViT with a feed-forward layer applied over the patch dimension.
  • Use the same architecture and training regime as ViT/DeiT baselines for fair comparison.
  • Train ViT/DeiT tiny, base, and large configurations on ImageNet with 224px resolution.
  • Compare performance of FF-only networks to their attention-based counterparts across model sizes.

Experimental results

Research questions

  • RQ1How does removing the attention mechanism and using a feed-forward layer over patches affect ImageNet top-1 accuracy?
  • RQ2Which components (patch embedding, training augmentations) drive the strong performance of Vision Transformers?
  • RQ3Can a feed-forward-only architecture achieve competitive results across standard ViT/DeiT sizes?

Key findings

  • FF-only models achieve strong accuracy, e.g., base-sized FF-only reaches 74.9% top-1 on ImageNet.
  • Attention-free models perform worse than attention-based ones but remain surprisingly strong across sizes.
  • Base-sized FF-only models are substantially more accurate than tiny FF-only models but behind ViT/DeiT with attention.
  • Large FF-only models degrade in performance relative to base/ViT under the studied setup.
  • Pure attention-only models (small) perform poorly in this setup, underscoring the limited benefit of attention without FF components.
  • Training regime and patch embedding contribute to the observed performance, not just the attention mechanism.

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.