Beyond Self-attention: External Attention using Two Linear Layers for Visual Tasks
arXiv:2105.02358
Abstract
Attention mechanisms, especially self-attention, have played an increasingly important role in deep feature representation for visual tasks. Self-attention updates the feature at each position by computing a weighted sum of features using pair-wise affinities across all positions to capture the long-range dependency within a single sample. However, self-attention has quadratic complexity and ignores potential correlation between different samples. This paper proposes a novel attention mechanism which we call external attention, based on two external, small, learnable, shared memories, which can be implemented easily by simply using two cascaded linear layers and two normalization layers; it conveniently replaces self-attention in existing popular architectures. External attention has linear complexity and implicitly considers the correlations between all data samples. We further incorporate the multi-head mechanism into external attention to provide an all-MLP architecture, external attention MLP (EAMLP), for image classification. Extensive experiments on image classification, object detection, semantic segmentation, instance segmentation, image generation, and point cloud analysis reveal that our method provides results comparable or superior to the self-attention mechanism and some of its variants, with much lower computational and memory costs.
11 pages, 6 figures. external attention and EAMLP
References in corpus (22)
- Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift
- PyTorch: An Imperative Style, High-Performance Deep Learning Library
- BioBERT: a pre-trained biomedical language representation model for biomedical text mining
- Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
- GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium
- Transformers in Vision: A Survey
- Self-Attention Generative Adversarial Networks
- Improved Training of Wasserstein GANs
- Recurrent Models of Visual Attention
- MMDetection: Open MMLab Detection Toolbox and Benchmark
- OCNet: Object Context Network for Scene Parsing
- Layer Normalization
- Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers
- Pre-Trained Image Processing Transformer
- Expectation-Maximization Attention Networks for Semantic Segmentation
- CPTR: Full Transformer Network for Image Captioning
- TransReID: Transformer-based Object Re-Identification
- Asymmetric Non-local Neural Networks for Semantic Segmentation
- End-to-End Video Instance Segmentation with Transformers
- Multiscale Vision Transformers
- Is Attention Better Than Matrix Decomposition?
Cited by in corpus (17)
- A Survey on Visual Transformer
- Attention Mechanisms in Computer Vision: A Survey
- ViTAE: Vision Transformer Advanced by Exploring Intrinsic Inductive Bias
- Query2Label: A Simple Transformer Way to Multi-Label Classification
- CycleMLP: A MLP-like Architecture for Dense Prediction
- AS-MLP: An Axial Shifted MLP Architecture for Vision
- S-MLPv2: Improved Spatial-Shift MLP Architecture for Vision
- S-MLP: Spatial-Shift MLP Architecture for Vision
- Vision Permutator: A Permutable MLP-Like Architecture for Visual Recognition
- Softmax-free Linear Transformers
- TransLoc3D : Point Cloud based Large-scale Place Recognition using Adaptive Receptive Fields
- Rethinking Token-Mixing MLP for MLP-based Vision Backbone
- An Image Patch is a Wave: Phase-Aware Vision MLP
- PoNet: Pooling Network for Efficient Token Mixing in Long Sequences
- Tab-Attention: Self-Attention-based Stacked Generalization for Imbalanced Credit Default Prediction
- Sampling Equivariant Self-attention Networks for Object Detection in Aerial Images
- Can Attention Enable MLPs To Catch Up With CNNs?