Activating Self-Attention for Multi-Scene Absolute Pose Regression

Miso Lee, Jihwan Kim, Jae-Pil Heo

Introduction

Absolute Pose Regression (APR) is a computer vision task focused on estimating a camera's exact 6-degree-of-freedom (6-DoF) pose from a single RGB image. Multi-Scene APR (MS-APR) pushes this boundary by training a single model to navigate multiple distinct environments simultaneously. While modern architectures like the MSTransformer leverage self-attention to capture global context, recent findings indicate these modules often suffer from "collapse," where the model ignores global relationships in favor of local features.

The Challenge of Self-Attention Collapse

In MS-APR, the Transformer encoder is designed to integrate global image context. However, researchers identified a "bypassing" phenomenon: the model actively avoids using self-attention because extrapolating poses across multiple scenes is computationally difficult. This results in "collapsed" attention maps where the model focuses on a few non-informative pixels rather than structural landmarks like long edges or architectural corners.

Investigation using t-SNE visualizations revealed a fundamental distortion in the embedding space. In a healthy Transformer, queries ($Q$) and keys ($K$) should overlap to facilitate interaction. In baseline MS-APR models, $Q$ and $K$ are mapped to entirely different regions of the high-dimensional space. This physical separation prevents the dot-product attention mechanism from functioning, effectively turning the Transformer into a local-feature extractor and wasting its global reasoning capacity.

Proposed Methodology: Activating the Encoder

To "activate" these dormant modules, the authors introduced two primary interventions that require no additional computational overhead during inference.

Query-Key Alignment (QKA) Loss

The core of the solution is the Query-Key Alignment (QKA) loss, an auxiliary training objective. This loss calculates the distance between the average query vector and the average key vector. By minimizing this distance, the model is forced to project queries and keys into a shared neighborhood. This alignment ensures the self-attention mechanism can compute meaningful relationships between image patches.

Figure 1: Comparison of Query-Key embedding spaces and attention maps between the baseline (left) and the proposed 'activated' model (right).

Fixed 2D Sinusoidal Positional Encoding

While many Transformers use learnable positional encodings, these often remain "undertrained" in the complex MS-APR setting. The authors replaced these with fixed, mathematically defined 2D sinusoidal encodings. This provides the model with reliable, consistent spatial clues from the first iteration of training, aiding the self-attention mechanism in organizing visual information geographically.

Experimental Results and Insights

The "activated" model was benchmarked against the Cambridge Landmarks (outdoor) and 7Scenes (indoor) datasets. The results demonstrated a clear superiority over existing MS-APR methods:

  • Outdoor Performance: On the Cambridge Landmarks dataset, the median error was reduced from 1.28m / 2.73° to 1.19m / 2.29°.
  • Indoor Performance: Orientation error on the 7Scenes dataset improved from 7.28° to 6.64°.
  • Localization Recall: The percentage of frames localized within a strict 1m/5° threshold on the Cambridge dataset rose from 32.6% to 35.8%.

The authors used "Attention Entropy" as a proxy for model health. Higher entropy indicates that attention is spread across meaningful features rather than collapsed. The proposed method significantly boosted entropy across all Transformer layers. Importantly, because QKA loss is only used during training and positional encodings are fixed, these improvements come with zero inference overhead.

Conclusion and Future Work

By diagnosing and correcting embedding space distortion, this research demonstrates that self-attention can be effectively "activated" for multi-scene tasks. While the current approach assumes images contain useful global features, future work could involve adaptive mechanisms to balance global and local features in dynamic or feature-poor environments. Nonetheless, QKA loss provides a simple yet powerful tool for ensuring Transformer-based models reach their full potential in geometric reasoning tasks.

Summary updated

BibTeX
@inproceedings{lee2024activating,
  author = {Miso Lee and Jihwan Kim and Jae-Pil Heo},
  title = {{Activating Self-Attention for Multi-Scene Absolute Pose Regression}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=rM24UUgZg8},
}
Figure