A^2-Nets: Double Attention Networks

Yunpeng Chen, Yannis Kalantidis, Jianshu Li, Shuicheng Yan, Jiashi Feng

TL;DR

$A^2$-Nets introduce a "double attention" block that allows neural networks to efficiently capture long-range dependencies across images and videos. By first gathering global features into a compact set and then adaptively distributing them back to each location, the authors created a model that outperforms the massive ResNet-152 on ImageNet while using 40% fewer parameters.

The Problem with "Nearsighted" CNNs

Standard Convolutional Neural Networks (CNNs) are inherently "nearsighted." A single convolution layer only looks at a small local neighborhood (like a 3x3 or 7x7 patch). To understand the relationship between distant parts of an image—or distant frames in a video—CNNs must stack many layers to gradually expand their "receptive field."

This approach is inefficient for several reasons:

  1. Bloat: Stacking layers makes models unnecessarily deep, increasing memory and computation costs.
  2. Optimization Difficulty: Information has to travel through many layers, making it harder for the network to learn effectively.
  3. Information Dilution: By the time a distant feature is "visible" to a specific location, it has been processed and potentially diluted by several intervening layers.

While previous solutions like "Non-local Networks" addressed this by correlating every single pixel with every other pixel, they were computationally expensive, scaling quadratically ($O(N^2)$) with the input size.

The Double Attention ($A^2$) Block

To overcome these limitations, the authors propose the Double Attention ($A^2$) block, which breaks the global context problem into two distinct, highly efficient steps:

  1. Feature Gathering: Instead of computing dense pixel-to-pixel correlations, the network uses "second-order attention pooling" to aggregate key features from the entire space (or spatio-temporal volume in videos) into a compact "bag of visual primitives." This captures complex global statistics, such as texture or lighting, far better than simple average pooling.
  2. Feature Distribution: Once the global "bag" of descriptors is created, the network employs a second attention mechanism to select which features are most relevant for each specific location. Each pixel receives a customized "care package" of global information that complements its local features.
Overview of the Double Attention block

The Math Trick: Mathematically, this operation can be viewed as two matrix multiplications. By leveraging the associative property of matrix multiplication, the authors change the order of operations to achieve the same result as a Non-local Network but with a massive reduction in memory and computational overhead.

Key Insights and Advantages

  • Efficiency through Bottlenecks: Instead of an $N \times N$ correlation (where $N$ is the number of pixels), $A^2$-Nets go from $N \to M \to N$, where $M$ is a small, compact number of global descriptors. This reduces the computational complexity from quadratic to linear.
  • Second-Order Statistics: Simple global pooling (like in SENet) only captures "first-order" information. By using the outer product of feature maps, $A^2$-Nets capture "second-order" correlations, which are much better at representing complex patterns and motion.
  • Strategic Placement: The authors found that $A^2$ blocks are most effective when placed in the later stages of a network. Higher layers deal with semantically rich concepts (like "wheels" or "faces") that benefit the most from global context.

Experimental Results

The researchers evaluated $A^2$-Nets on major benchmarks for both image and video recognition:

  • Image Classification (ImageNet-1k): A ResNet-50 equipped with $A^2$ blocks achieved 77.0% Top-1 accuracy. This matches the performance of the much larger ResNet-152 but uses 40% fewer parameters and significantly fewer FLOPs.
  • Video Action Recognition (Kinetics & UCF-101): On the Kinetics dataset, the $A^2$-Net achieved state-of-the-art results (74.6% Top-1 accuracy), outperforming heavyweights like I3D and R(2+1)D while using only 8 frames of input compared to their 32 or 64 frames.
  • Memory Savings: In practical terms, for a standard video input, the $A^2$ approach can use just 1MB of memory for its intermediate steps, whereas a standard Non-local approach might require over 2GB.

Future Directions

While $A^2$-Nets are highly effective, the authors note room for future exploration:

  • Integration with Mobile Architectures: The current study focused on ResNet backbones. Exploring how these blocks could boost "mobile-friendly" models like ShuffleNet or MobileNet is a promising next step.
  • Early Layer Utility: The performance gain is less significant when the blocks are placed in very early layers, likely because low-level features (like edges) don't benefit as much from global context as high-level semantic features do.

Summary updated

BibTeX
@inproceedings{chen2018nets,
  author = {Yunpeng Chen and Yannis Kalantidis and Jianshu Li and Shuicheng YAN and Jiashi Feng},
  title = {{A^2-Nets: Double Attention Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2018},
  url = {https://openreview.net/forum?id=BJbPTD-O-S},
}
Figure