Abstract
Vision transformers require a huge amount of labeled data to outperform convolutional neural networks. However, labeling a huge dataset is a very expensive process. Self-supervised learning techniques alleviate this problem by learning features similar to supervised learning in an unsupervised way. In this paper, we propose a self-supervised technique PatchRot that is crafted for vision transformers. PatchRot rotates images and image patches and trains the network to predict the rotation angles. The network learns to extract both global and local features from an image. Our extensive experiments on different datasets showcase PatchRot training learns rich features which outperform supervised learning and compared baseline.
Introduction
While Vision Transformers (ViTs) have recently surpassed Convolutional Neural Networks (CNNs) in many tasks, they possess a significant limitation: they lack the "inductive biases" inherent in CNNs. CNNs are architecturally designed to exploit spatial locality and translation equivariance. In contrast, ViTs treat images as sequences of patches, meaning they must learn these fundamental spatial rules from scratch. This makes ViTs exceptionally "data-hungry," often requiring massive labeled datasets to reach their full potential. To address the high cost of manual labeling, we propose PatchRot, a self-supervised learning (SSL) technique specifically tailored for the Transformer architecture.
Methods
PatchRot extends the classic "RotNet" concept by introducing a dual-task framework that forces the model to capture both global and local features.
Dual Rotation Tasks
The model is trained on two distinct pretext tasks:
- Global Rotation: The entire image is rotated by one of four angles (0°, 90°, 180°, or 270°). The standard classification head (class token) is tasked with predicting this angle.
- Local Patch Rotation: The image remains upright, but individual patches are rotated by random angles. Auxiliary MLP heads are attached to each patch output to predict these local rotations.
Implementation Details
To prevent the model from "cheating" by simply matching edges between adjacent patches (edge continuity), a buffer gap is introduced between patches during training. This ensures the network learns the semantic content of the patches rather than low-level boundary features. After pre-training, the auxiliary heads are removed, and the model is fine-tuned for downstream tasks like object classification.
Results and Discussion
Extensive evaluations were conducted on benchmarks including CIFAR-10, CIFAR-100, FashionMNIST, and Tiny-ImageNet.
Performance Comparison
PatchRot consistently outperformed both standard supervised learning and the image-level RotNet baseline. For instance, on CIFAR-10, PatchRot achieved 92.6% accuracy, significantly higher than the 83.2% achieved via standard supervision.
Key Insights
- Local Feature Extraction: By incorporating patch-level rotation, PatchRot ensures the Transformer's attention mechanism learns to identify meaningful local textures and shapes, effectively compensating for the lack of CNN-like inductive biases.
- Rotation Invariance: PatchRot showed superior performance on digit datasets (SVHN/MNIST). Even when a whole digit might appear rotation-invariant, the internal textures of its patches provide sufficient signal for the model to learn robust features.
- Low-Data Efficiency: In semi-supervised settings with only 1,000 labeled samples on CIFAR-10, PatchRot reached 70.1% accuracy, compared to just 38.6% for a model trained from scratch.
Conclusion
PatchRot demonstrates that self-supervised rotation tasks, when applied at both global and local scales, can significantly improve the performance and data efficiency of Vision Transformers. While current experiments focused on "ViT-Lite" models due to hardware constraints, the results suggest that PatchRot is a powerful tool for priming Transformers with spatial awareness. Future work will involve scaling these methods to larger datasets like ImageNet and exploring their utility in domains where orientation is typically fixed, such as medical imaging.
Summary updated