A Generic Shared Attention Mechanism for Various Backbone Neural Networks
Zhongzhan Huang, Senwei Liang, Mingfu Liang, Liang Lin
TL;DR
This work identifies a strong cross-layer correlation in self-attention maps, revealing that per-block SAMs are parameter-inefficient when networks deepen. It proposes Dense-and-Implicit-Attention (DIA), a layerwise shared attention unit, and DIA-LSTM, which uses a GAP-augmented LSTM to bridge current and prior layer information, offering substantial parameter savings while improving performance across ResNet, Transformer, and UNet backbones on classification, generation, and detection tasks. DIA achieves dense, implicit cross-layer connections and acts as a regularizer that stabilizes training, with lightweight variants (DIA-LSTM Light) that retain most benefits while minimizing overhead. The approach demonstrates statistically significant gains over multiple SAMs and backbones on benchmarks like CIFAR, STL-10, ImageNet, MS COCO, and medical imaging, and provides practical guidance on deployment, including cost considerations and BN-sharing caveats. Overall, DIA presents a broadly applicable method to improve attention module efficiency and network performance in diverse vision problems.
Abstract
The self-attention mechanism has emerged as a critical component for improving the performance of various backbone neural networks. However, current mainstream approaches individually incorporate newly designed self-attention modules (SAMs) into each layer of the network for granted without fully exploiting their parameters' potential. This leads to suboptimal performance and increased parameter consumption as the network depth increases. To improve this paradigm, in this paper, we first present a counterintuitive but inherent phenomenon: SAMs tend to produce strongly correlated attention maps across different layers, with an average Pearson correlation coefficient of up to 0.85. Inspired by this inherent observation, we propose Dense-and-Implicit Attention (DIA), which directly shares SAMs across layers and employs a long short-term memory module to calibrate and bridge the highly correlated attention maps of different layers, thus improving the parameter utilization efficiency of SAMs. This design of DIA is also consistent with the neural network's dynamical system perspective. Through extensive experiments, we demonstrate that our simple yet effective DIA can consistently enhance various network backbones, including ResNet, Transformer, and UNet, across tasks such as image classification, object detection, and image generation using diffusion models.
