Abstract
Benefiting from the capability of building inter-dependencies among channels or spatial locations, attention mechanisms have been extensively studied and broadly used in a variety of computer vision tasks recently. In this paper, we investigate light-weight but effective attention mechanisms and present triplet attention, a novel method for computing attention weights by capturing cross-dimension interaction using a three-branch structure. For an input tensor, triplet attention builds inter-dimensional dependencies by the rotation operation followed by residual transformations and encodes inter-channel and spatial information with negligible computational overhead. Our method is simple as well as efficient and can be easily plugged into classic backbone networks as an add-on module. We demonstrate the effectiveness of our method on various challenging tasks including image classification on ImageNet-1k and object detection on MSCOCO and PASCAL VOC datasets. Furthermore, we provide extensive insight into the performance of triplet attention by visually inspecting the GradCAM and GradCAM++ results. The empirical evaluation of our method supports our intuition on the importance of capturing dependencies across dimensions when computing attention weights.
Introduction
In modern Convolutional Neural Networks (CNNs), attention mechanisms are critical for focusing on salient features. Existing methods typically categorize into Channel Attention (e.g., SE-Net), which identifies which feature maps are important, and Spatial Attention (e.g., CBAM), which identifies where in the image to focus.
However, these approaches often treat channel and spatial dimensions as independent, ignoring "cross-dimension interactions." For instance, a specific channel might be highly relevant only to a specific vertical slice of an image. Furthermore, many modules rely on dimensionality reduction to save computation, which can destroy inter-channel relationships. This paper introduces the Convolutional Triplet Attention Module (TAM) to capture these complex interactions without the computational bottleneck of dimensionality reduction.
The Triplet Attention Module (TAM)
The core innovation of TAM is its three-branch structure that captures dependencies across all three dimensions of a tensor (Channel $C$, Height $H$, and Width $W$). Instead of looking only at the standard $(H, W)$ spatial plane, TAM views the tensor from three different "perspectives":
- Spatial Attention Branch: Captures dependencies between Height ($H$) and Width ($W$) by squashing the channel dimension.
- Channel-Height Branch: Rotates the input tensor so that Channel ($C$) and Height ($H$) dimensions form the spatial plane, capturing vertical-channel interactions.
- Channel-Width Branch: Rotates the tensor to capture interactions between Channels ($C$) and Width ($W$).
Implementation and Z-Pool
To maintain efficiency, each branch utilizes a Z-pool layer. Unlike standard global pooling, Z-pool concatenates the Max-pool and Average-pool results along the zeroth dimension. This preserves a rich representation while reducing the tensor's depth to two slices. These slices are processed by a $7 \times 7$ convolution and a sigmoid activation to generate attention weights. The outputs of the three branches are then aggregated via averaging.
Experimental Results
The Triplet Attention Module was validated across several industry-standard benchmarks, demonstrating significant gains with minimal parameter overhead:
- ImageNet-1k Classification: Integrating TAM into a ResNet-50 increased Top-1 accuracy by 2.28%, adding only 4,800 parameters. In contrast, SE-Net adds over 2.5 million parameters for a smaller accuracy gain.
- Object Detection (MSCOCO): Using a Faster R-CNN with a ResNet-50 backbone, TAM improved the Mean Average Precision (mAP) by 2.9 points over the baseline.
- Mobile Efficiency: On MobileNetV2, TAM improved accuracy by nearly 1% with negligible impact on FLOPs, making it highly suitable for edge device deployment.
Conclusion
Triplet Attention demonstrates that capturing cross-dimensional dependencies through simple rotation and residual transformations is both effective and efficient. By avoiding the dimensionality bottlenecks of previous attention mechanisms, TAM provides superior localization and performance across classification and detection tasks while remaining nearly parameter-free. Future work may extend this rotation-based logic to 3D vision tasks such as video processing and medical imaging.
Summary updated