Rethinking the Fully Hyperbolic Vision Transformer in Polar Coordinates
Organizations: Data Science Group University of Hildesheim Hildesheim, Germany
Abstract
Hyperbolic space can embed intrinsic hierarchies in data with low distortion due to the exponential growth of volume with distance from the origin. However, current Lorentz transformer blocks are formulated in ambient coordinates, where numerical errors increase at large radii due to instability in the Lorentzian inner product, leading many models to limit the radius to avoid this issue. This prevents us from utilizing the regions of hyperbolic space that motivate the geometry. To address this, we revisit the components of the transformer block in polar coordinates, where hyperbolic operations such as distance calculation and attention centroids can be computed without the numerical cancellation in their ambient-coordinate formulations. Specifically, we propose a polar fully connected layer that separately maps an embedding's direction and radius, allowing the radius of a feature to be learned rather than determined by the norm of a linear map. We additionally introduce horospherical shifts as relative positional encodings whose query-key distances grow logarithmically with the token gap. Finally, we reformulate the residual connection as average radius Lorentz boosts. Combining these components, we develop a fully hyperbolic transformer that substantially improves performance over Euclidean and hyperbolic baselines on standard vision tasks. We further evaluate our model on ImageNet and demonstrate its ability to generalize to other datasets using pre-trained weights, similar to Euclidean counterparts.
Figures & tables
| Model | Size | CIFAR-100 | Tiny-ImageNet |
|---|---|---|---|
| Euclidean ViT | Tiny | ||
| HexFormer | Tiny | ||
| HexFormer-Hybrid | Tiny | ||
| Polar-ViT w/o horoshift | Tiny | ||
| Polar-ViT | Tiny | ||
| HVT ( Fein-Ashley et al., 2024 ) | Base | 42.77 | 40.12 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| Operation | Weights | Condition for correctness |
|---|---|---|
| Attention aggregation | Softmax row with leak | |
| Manifold weight decay, centroid residual | ||
| Batch-norm mean, token pooling | Uniform | or |
| Gyro-norm centering | — |
| Change | Component | Accuracy |
|---|---|---|
| Split-head Lorentz ViT, class-token readout | — | |
| + polar change of current ops and gyrolayer norm | - | |
| + boost residual | Section 4.4 | |
| + polar boost residual | Eq. ( 12 ) | |
| + polar fully connected layer | Eq. ( 8 ) | |
| + horospherical positional encoding (Polar-ViT) | Eq. ( 10 ) |
| Radius rule | Accuracy |
|---|---|
| Anchored gain, Eq. ( 8 ) | |
| Anchored gain, | 78.02 |
| Anchored gain, | 77.36 |
| Free power of the pre-activation norm | 75.22 |
| Affine in the input radius, Klein input | 75.06 |
| Affine in the input radius, unit-direction input | 74.42 |
| Squared distance | Centroid | Gyro-norm centering | |||||
|---|---|---|---|---|---|---|---|
| Ambient | Polar | Ambient | Polar | Ambient | Polar | Resolution limit | |
| 4 | |||||||
| 8 | |||||||
| 12 | NaN | ||||||
| Model | fp32 |
|---|---|
| Euclidean ViT | 21 ms |
| Lorentz ViT, ambient arithmetic | 52 ms |
| Polar-ViT, polar arithmetic | 58 ms |
| Model | Params | ISIC 2016 | ISIC 2018 | Kvasir-SEG | SANET | BUSI | |
|---|---|---|---|---|---|---|---|
| published | Euclidean U-Net | K | |||||
| Poincaré U-Net | K | ||||||
| ours | Lorentz U-Net, ambient | K | |||||
| Lorentz U-Net, polar | K |
Vision Transformer
Vision Transformers (ViTs) use self-attention over image patches to learn visual representations for recognition, segmentation, and other tasks.
See all 352 papers