SimA: Simple Softmax-free Attention for Vision Transformers
Preprint
Abstract
Recently, vision transformers have become very popular. However, deploying them in many applications is computationally expensive partly due to the Softmax layer in the attention block. We introduce a simple but effective, Softmax-free attention block, SimA, which normalizes query and key matrices with simple $\ell_1$-norm instead of using Softmax layer. Then, the attention block in SimA is a simple multiplication of three matrices, so SimA can dynamically change the ordering of the computation at the test time to achieve linear computation on the number of tokens or the number of channels. We empirically show that SimA applied to three SOTA variations of transformers, DeiT, XCiT, and CvT, results in on-par accuracy compared to the SOTA models, without any need for Softmax layer. Interestingly, changing SimA from multi-head to single-head has only a small effect on the accuracy, which simplifies the attention block further. The code is available here: https://github.com/UCDvision/simaKeywords
All Related Versions
This publication has 7 references indexed in Scilit:
- Beyond Self-Attention: External Attention Using Two Linear Layers for Visual TasksIEEE Transactions on Pattern Analysis and Machine Intelligence, 2022
- ResMLP: Feedforward Networks for Image Classification With Data-Efficient TrainingIEEE Transactions on Pattern Analysis and Machine Intelligence, 2022
- Hire-MLP: Vision MLP via Hierarchical Rearrangement2022
- Masked Autoencoders Are Scalable Vision Learners2022
- Towards Fully 8-bit Integer Inference for the Transformer Model2020
- Efficient Precision-Adjustable Architecture for Softmax Function in Deep LearningIEEE Transactions on Circuits and Systems II: Express Briefs, 2020
- Fully Quantized Transformer for Machine Translation2020