Auto Learning Attention

Benteng Ma, Jing Zhang, Yong Xia, Dacheng Tao

Attention mechanisms have become a staple in Convolutional Neural Networks (CNNs), helping models focus on informative channels or spatial regions. However, most existing attention modules—such as Squeeze-and-Excitation (SE) or Convolutional Block Attention Module (CBAM)—are "hand-crafted" by experts.

Presented at NeurIPS 2020, Auto Learning Attention (AutoLA) introduces a framework that applies Neural Architecture Search (NAS) to the design of attention modules. By moving away from manually designed structures, the authors demonstrate that an automated, "high-order" approach can create more effective, plug-and-play attention components that generalize across various vision tasks.

The Problem: Limitations of Manual Design

Historically, attention designs have been limited to "first-order" (a single operation) or "second-order" (stacking channel and spatial attention sequentially) structures. The authors identify two main gaps in this paradigm:

  1. Manual Design Limitations: Designing complex, high-order attention structures is computationally expensive and requires significant human intuition, which may not always yield optimal feature representations.
  2. Search Space Complexity: Exhaustively searching for the best way to arrange basic attention units leads to an exponential explosion in possible architectures.
Comparison of first-order, second-order, and the proposed high-order (HOGA) attention mechanisms.

AutoLA aims to automate this process, finding optimal "high-order" structures that are significantly more powerful than simple sequential stacks.

The core of the paper relies on the High Order Group Attention (HOGA) module and the AutoLA search process.

HOGA Architecture

The authors represent an attention module as a Directed Acyclic Graph (DAG).

  • Nodes: The input feature map is split into $K$ groups along the channel dimension. Each group represents a node in the graph.
  • Edges: Each edge represents a specific attention operation chosen from a predefined search space.

The algorithm can choose from several operations, including standard Channel Attention, Spatial Attention, Normalization Attention, CBAM, as well as Identity and Zero mappings.

Differentiable Search Space

To avoid the prohibitive cost of training thousands of individual architectures from scratch, AutoLA uses a differentiable search method inspired by DARTS.

The differentiable architecture search phase, showing multiple weighted operation paths between nodes.

It relaxes the categorical choice of operations into a softmax over all possibilities, allowing the architecture to be optimized directly via gradient descent. The search is highly efficient: performed on a small backbone (ResNet-20) on CIFAR-10, it takes only about 1 GPU day. Once found, the resulting HOGA module is "plug-and-play" and can be inserted into much larger models like ResNet-101 or ResNeXt.

Key Insights and Results

AutoLA was evaluated across standard benchmarks including CIFAR, ImageNet (ILSVRC2012), and COCO (for downstream tasks like Object Detection and Human Keypoint Detection).

  • Higher Order = Better Representation: The "high-order" nature of HOGA allows the model to learn more complex relationships between features than simple sequential attention. The searched modules often contain intricate connections that a human designer would likely never consider.
  • Grouping for Efficiency: By splitting features into groups (e.g., $K=4$), the authors manage the computational cost of high-order operations, keeping the parameter and FLOP increase relatively low.
  • Remarkable Generalization: An attention module searched on a tiny ResNet-20 model on CIFAR-10 generalizes perfectly to a ResNet-101 on ImageNet or a detection task on COCO. This suggests that "good attention" is a somewhat universal property of feature maps.
  • State-of-the-Art Performance:
    • ImageNet Classification: ResNet-50 with AutoLA achieved a 21.82% Top-1 error, significantly outperforming the vanilla baseline (24.56%) and manual designs like SE (23.14%) and CBAM (22.66%).
  • Object Detection (COCO): Using the SSD framework with a ResNet-50 backbone, AutoLA improved the Average Precision (AP) by 2.77 points over the vanilla backbone.
  • Keypoint Detection (COCO): AutoLA achieved 74.6 AP, outperforming both SE and CBAM (both at 73.6 AP).

Limitations and Future Work

While highly effective, AutoLA currently relies on a decoupled search—the attention module is searched given a fixed backbone. Searching the backbone and the attention module simultaneously in a unified framework remains a promising direction for future work. Additionally, while $K=4$ provided a good trade-off in experiments, the "order" of the attention remains a manual hyperparameter. Finally, in strictly resource-constrained environments, the trade-off between the extra ~10-15% FLOPs introduced by AutoLA and the resulting accuracy gains requires careful consideration.

Summary updated

BibTeX
@inproceedings{ma2020auto,
  author = {Benteng Ma and Jing Zhang and Yong Xia and Dacheng Tao},
  title = {{Auto Learning Attention}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure