Abstract
Vision Transformers (ViTs) have become a cornerstone of modern computer vision, yet they remain surprisingly sensitive to small spatial shifts in input images. This sensitivity stems from fixed-grid operations like patch tokenization and window-based attention, which break shift-equivariance. This paper introduces a family of "Adaptive" (A-) modules designed to restore this property by making architectural components data-dependent. By dynamically aligning grids to the input signal, the proposed A-ViTs achieve 100% circular shift consistency across major architectures (Swin, MViT, CvT) while maintaining or improving performance on image classification and semantic segmentation benchmarks.
Introduction: The Shift-Equivariance Challenge
In computer vision, shift-equivariance is a desirable property where a spatial shift in the input image results in an identical shift in the output (e.g., a segmentation mask). While Convolutional Neural Networks (CNNs) were designed with this intuition, modern Vision Transformers (ViTs) often fail this test. The primary culprit is the "fixed grid" nature of standard ViTs. Patch tokenization splits an image into patches based on a static coordinate system; a single-pixel shift can completely change the content of these patches. Similarly, window-based attention and patch merging operations rely on fixed spatial boundaries that do not move with the object of interest.
Proposed Adaptive Modules
To address these limitations, the authors propose a "data-adaptive" design principle. Instead of using rigid grids, each module's behavior adapts to the input signal to ensure consistent alignment. Four key modules are introduced:
Adaptive Tokenization (A-token)
Standard tokenization is sensitive to the starting point of the grid. A-token considers all possible circular shifts of the input and selects the one that maximizes a shift-invariant "energy" function. This ensures that the same patches are extracted regardless of the input's initial shift.
Adaptive Window-based Self-Attention (A-WSA)
Similar to tokenization, A-WSA dynamically selects window offsets based on local signal energy. This ensures that the same groups of tokens are processed together in self-attention layers, even if the input is shifted.
Adaptive Patch Merging and Position Embeddings
The framework also includes Adaptive Patch Merging (A-PMerge), which replaces standard strided downsampling with Adaptive Polyphase Sampling (APS) to select downsampling indices based on signal norms, and Adaptive Relative Position Embedding (RPE), which utilizes circular distances to maintain consistency under shifts.
Experimental Evaluation
The researchers integrated these modules into popular architectures like Swin, SwinV2, CvT, and MViTv2, evaluating them on ImageNet-1K, CIFAR, and ADE20K.
Key Results
- Perfect Consistency: Under circular shifts, A-models achieved 100% shift consistency, a significant improvement over the 75-85% range seen in standard ViTs.
- Performance Gains: Equivariance acts as a powerful inductive bias. On CIFAR-100, A-Swin-T reached 75.11% accuracy, compared to the baseline's 71.01%.
- Segmentation Robustness: In semantic segmentation (ADE20K), A-Swin models maintained perfect consistency (100% mASCC) under circular shifts and produced visibly more stable masks under standard linear shifts.
- Computational Trade-off: The adaptive alignment logic introduces a small throughput decrease of roughly 10-20%, though the parameter count remains unchanged.
Conclusion
This work demonstrates that shift-equivariance in Vision Transformers is primarily an alignment problem. By replacing fixed grids with data-adaptive components, models can become robust to spatial shifts without sacrificing accuracy. While 100% consistency is theoretically guaranteed for circular shifts, the practical improvements in standard linear shifts suggest that adaptive alignment is a vital step toward more robust and reliable vision models.
Summary updated