Attention Maps are visualizations of the attention weights \( \alpha_{ij} \), which are computed in attention mechanisms of neural networks to represent the relative importance of input elements \( j \) for the processing of a target element \( i \).
Formally, in an attention mechanism, the scores \( e_{ij} \) are calculated by a function such as
\[ e_{ij} = rac{(Q_i)(K_j)^T}{\sqrt{d_k}} \]
where \( Q_i \) is the query vector, \( K_j \) the key vector, and \( d_k \) the dimension of the keys.
The attention weights follow by softmax:
\[ \alpha_{ij} = rac{\exp(e_{ij})}{\sum_{k} \exp(e_{ik})} \]
These weights are visualized in attention maps as heatmaps and show which input elements are dominant during processing.
Attention Maps are essential for understanding and explaining models like the Transformer by providing insight into the focus distribution during model inference.
Definition:
“Attention Maps are visualizations of the weightings computed by attention mechanisms that indicate how strongly individual input elements are considered during the processing of a target element.”
Source:
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (2017). Attention is All You Need. Advances in Neural Information Processing Systems, 30.