Abstract
Vision Transformer (ViT) has achieved remarkable performance in computer vision. However, positional encoding in ViT makes it substantially difficult to learn the intrinsic equivariance in data. Initial attempts have been made on designing equivariant ViT but are proved defective in some cases in this paper. To address this issue, we design a Group Equivariant Vision Transformer (GE-ViT) via a novel, effective positional encoding operator. We prove that GE-ViT meets all the theoretical requirements of an equivariant neural network. Comprehensive experiments are conducted on standard benchmark datasets, demonstrating that GE-ViT significantly outperforms non-equivariant self-attention networks.
Introduction
In computer vision, equivariance is a desirable property where a transformation of the input image (e.g., rotation or reflection) results in a predictable, corresponding transformation of the model's internal representations. While Convolutional Neural Networks (CNNs) possess inherent translation equivariance, Vision Transformers (ViTs) struggle with this. ViTs process images as sets of patches and rely on positional encodings to maintain spatial context. Unfortunately, standard absolute or relative positional encodings typically break equivariance for rotations and reflections, as these encodings do not "rotate" with the input.
The GE-ViT Architecture
The Group Equivariant Vision Transformer (GE-ViT) addresses these limitations by introducing a framework equivariant to the $E(2)$ group, which includes translations, rotations, and reflections. The architecture consists of two primary stages:
- Lifting Self-Attention: This initial layer transforms standard 2D image data into a group space $G$, representing both spatial positions and orientations.
- Group Self-Attention (GE Self-Attention): Operating within the group space, this layer performs self-attention across spatial positions and group elements (such as discrete rotation angles).
The core innovation lies in a corrected relative positional encoding formula. The authors identified mathematical inconsistencies in previous models like GSA-Net and proposed a new operator: $$\rho((i, \tilde{h}), (j, \hat{h})) = \rho^P(x(j) - x(i), \tilde{h}\hat{h}^{-1}\tilde{h})$$ This formulation ensures that attention scores remain consistent even when the input undergoes an $E(2)$ group transformation.
Equivariance and Visual Consistency
A key advantage of GE-ViT is its "steerability." By performing group operations directly on the positional encodings, the model can adapt its filters to any orientation without requiring extensive data augmentation. This theoretical robustness is reflected in the internal feature maps.
As shown in Figure 6, when an input digit is rotated, the resulting feature maps in GE-ViT undergo a corresponding cyclic permutation, maintaining the integrity of the learned features. This level of consistency is a significant improvement over previous equivariant transformer designs, which often show significant divergence in feature maps under transformation.
Experimental Results
GE-ViT was evaluated on several benchmarks to test its generalization capabilities:
- rotMNIST: On this rotation-heavy dataset, GE-ViT achieved a peak accuracy of 98.01% (using $R12$ symmetry), outperforming previous state-of-the-art GSA-Nets.
- PATCHCAMELYON: In medical imaging, where tissue orientation is arbitrary, GE-ViT reached 82.73% accuracy, a substantial lead over GSA-Net's 79.40%.
- CIFAR-10: Even on natural images, GE-ViT showed improved performance (70.40% vs. 69.31%), demonstrating that symmetry-aware architectures benefit general vision tasks.
Conclusion
GE-ViT provides a mathematically sound foundation for building equivariant Vision Transformers. By fixing the positional encoding flaws of prior work, it achieves superior performance and parameter efficiency across diverse datasets. Future work will focus on reducing the quadratic computational complexity of the self-attention mechanism to improve scalability for high-resolution imagery.
Summary updated