Exploring Self-attention for Image Recognition
Hengshuang Zhao, Jiaya Jia, Vladlen Koltun
TL;DR
This work investigates the viability of self-attention as a fundamental building block for image recognition, introducing two families—pairwise and patchwise self-attention—that decouple feature aggregation from transformation. Vector attention, enabling channel-aware, content-adaptive weights, and patchwise attention, which generalizes convolution, yield architectures that match or surpass convolutional ResNets on ImageNet with comparable or lower computational budgets. The study demonstrates that patchwise self-attention can outperform conv baselines by substantial margins, and pairwise attention achieves strong results with favorable efficiency. Robustness analyses reveal that self-attention networks improve zero-shot generalization to rotations and display increased resistance to adversarial attacks, suggesting broader benefits for generalization and reliability in vision systems.
Abstract
Recent work has shown that self-attention can serve as a basic building block for image recognition models. We explore variations of self-attention and assess their effectiveness for image recognition. We consider two forms of self-attention. One is pairwise self-attention, which generalizes standard dot-product attention and is fundamentally a set operator. The other is patchwise self-attention, which is strictly more powerful than convolution. Our pairwise self-attention networks match or outperform their convolutional counterparts, and the patchwise models substantially outperform the convolutional baselines. We also conduct experiments that probe the robustness of learned representations and conclude that self-attention networks may have significant benefits in terms of robustness and generalization.
