Cosine-Normalized Attention for Hyperspectral Image Classification
Organizations: SDAIA-KFUPM, Joint Research Center for Artificial Intelligence (JRCAI), King Fahd University of Petroleum and Minerals, Dhahran, 31261, Saudi Arabia · Institute of Software Development and Engineering, Innopolis University, Innopolis, 420500, Russia
Abstract
Transformer-based methods have improved hyperspectral image classification (HSIC) by modeling long-range spatial-spectral dependencies; however, their attention mechanisms typically rely on dot-product similarity, which mixes feature magnitude and orientation and may be suboptimal for hyperspectral data. This work revisits attention scoring from a geometric perspective and introduces a cosine-normalized attention formulation that aligns similarity computation with the angular structure of hyperspectral signatures. By projecting query and key embeddings onto a unit hypersphere and applying a squared cosine similarity, the proposed method emphasizes angular relationships while reducing sensitivity to magnitude variations. The formulation is integrated into a spatial-spectral Transformer and evaluated under extremely limited supervision. Experiments on three benchmark datasets demonstrate that the proposed approach consistently achieves higher performance, outperforming several recent Transformer- and Mamba-based models despite using a lightweight backbone. In addition, a controlled analysis of multiple attention score functions shows that cosine-based scoring provides a reliable inductive bias for hyperspectral representation learning.
Figures & tables
| Metric | Transformers | State Space Models | Proposed | ||||||||||||||||||||
| MSST | S2CIFT | S2CAT | WF | DF | SSAM | DBMLLA | WDM | MM | GM | PM | KDM | CS 2 | CS | SDP | DP | Add | SA | MSA-CS 2 | C-SDP | C-CS 2 | C-CS | C-Add | |
| SA Dataset | |||||||||||||||||||||||
| 97.97 | 95.65 | 95.78 | 94.90 | 94.06 | 87.80 | 92.28 | 89.26 | 88.38 | 95.85 | 98.16 | 92.44 | 99.15 | 98.60 | 99.18 | 97.75 | 98.93 | 99.24 | 99.23 | 98.76 | 99.33 | 98.16 | 98.75 | |
| OA | 98.17 | 96.10 | 96.21 | 95.42 | 94.67 | 89.07 | 93.06 | 90.35 | 89.56 | 96.27 | 98.35 | 93.22 | 99.23 | 98.74 | 99.26 | 97.98 | 99.04 | 99.32 | 99.31 | 98.88 | 99.40 | 98.35 | 98.87 |
| AA | 97.63 | 95.56 | 97.48 | 95.14 | 95.87 | 88.59 | 95.44 | 91.80 | 87.76 | 96.24 | 97.55 | 91.23 | 99.18 | 98.83 | 99.06 | 98.02 | 99.03 | 99.20 | 99.30 | 98.99 | 99.18 | 98.53 | 99.09 |
| HH Dataset | |||||||||||||||||||||||
| Analysis Group | Configuration | SA | HH | TD |
|---|---|---|---|---|
| Normalization | None | 98.11 0.12 | 97.64 0.15 | 98.42 0.11 |
| Query only | 98.74 0.09 | 97.93 0.12 | 98.58 0.10 | |
| Key only | 98.69 0.10 | 97.89 0.13 | 98.55 0.09 | |
| Query + Key | 99.24 0.05 | 98.32 0.07 | 98.84 0.06 | |
| Squaring strategy | Cosine | 99.07 0.07 | 98.21 0.09 | 98.71 0.08 |
| 99.11 0.06 | 98.24 0.08 | 98.74 0.07 |