Explicitly Modeled Attention Maps for Image Classification

Andong Tan, Duc Tam Nguyen, Maximilian Dax, Matthias Nießner, Thomas Brox

Introduction

Self-attention has revolutionized computer vision, enabling models to capture long-range dependencies that standard convolutions often miss. However, this performance comes with a significant computational cost. Standard self-attention requires learning complex "key-query" relationships to determine how pixels interact. This paper investigates whether this complexity is necessary, proposing that explicitly modeled geometric functions can achieve superior results with far fewer parameters.

The Computational Burden of Self-Attention

In Attention Augmented Networks (AA-Net), pixels "attend" to the entire image by calculating similarity scores between learned "keys" and "queries." While effective, this process is computationally expensive. The authors observed that visualized attention maps often follow simple, predictable patterns—typically showing that a pixel's influence decays with distance. This suggests that the millions of FLOPs spent calculating these maps from scratch might be redundant.

Methods: Explicitly Modeled Attention (ExpAtt)

The authors introduce ExpAtt (Explicitly Modeled Attention), which replaces the standard $Softmax(QK^T)$ formula with predefined mathematical functions based on spatial distance.

Comparison between standard content-dependent attention and the proposed content-independent ExpAtt method.

Key components of ExpAtt include:

  • Geometric Priors: The model assumes a pixel’s relevance decreases as distance increases.
  • Parametric Functions: Various functions (Linear, Cosine, Exponential) were tested, with the Gaussian kernel proving most effective. In this setup, the only learnable parameter is the radius ($\sigma$).
  • Efficiency: ExpAtt drastically reduces parameter counts. While standard attention scales with $O(N \cdot C \cdot d)$, ExpAtt requires only one or zero learnable parameters per layer.
  • Hybrid Architecture: ExpAtt modules are concatenated with standard convolutional features, combining local feature extraction with global geometric context.

Key Insights and Ideas

The study revealed several critical properties of attention in vision models:

  • Geometry over Content: For many classification tasks, the spatial relationship between pixels is more informative than their specific content when generating attention maps.
  • The Shrinking Radius: Analysis of learned $\sigma$ values showed that the attention radius is typically larger in early layers and narrows in deeper layers, indicating a transition from global context to local refinement.
Learned attention radius across different network layers and datasets, showing a general trend of decreasing radius in deeper layers.
  • Regularization via Structure: Even a "Uniform" attention map outperformed standard ResNets, suggesting that the architectural addition of an attention branch provides a powerful regularization effect regardless of map complexity.
  • Redundancy of Content-Dependent Attention: Combining ExpAtt with traditional attention actually reduced accuracy, suggesting that expensive key-query calculations may introduce noise or redundancy.

Results

Evaluations on ImageNet (ILSVRC) demonstrated significant gains:

  • ResNet-50: Gaussian-ExpAtt achieved 78.13% Top-1 accuracy, surpassing the AA-ResNet50 baseline (77.70%).
  • ResNet-152: The method reached 80.02%, nearly 1% higher than the baseline.
  • Efficiency: ExpAtt reduced parameters by 6.4% and GFLOPs by 6.7% compared to AA-ResNet152.
  • Mobile Performance: On MobileNetV2, ExpAtt improved accuracy on Tiny ImageNet while maintaining a lower computational footprint than competing attention mechanisms.

Limitations and Future Work

While highly effective for classification, ExpAtt's performance varies by architecture, showing better results on "Bottleneck" residual blocks. Future research could explore dense prediction tasks like object detection or segmentation, where content-dependent attention might be more necessary for distinguishing overlapping objects. Given that spatial proximity is a fundamental property of images, ExpAtt serves as a promising, efficient drop-in replacement for attention in diverse vision backbones.

Summary updated

BibTeX
@inproceedings{tan2021explicitly,
  author = {Andong Tan and Duc Tam Nguyen and Maximilian Dax and Matthias Nießner and Thomas Brox},
  title = {{Explicitly Modeled Attention Maps for Image Classification}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i11.17178},
}
Figure