Abstract
As the field of deep learning steadily transitions from the realm of academic research to practical application, the significance of self-supervised pretraining methods has become increasingly prominent. These methods, particularly in the image domain, offer a compelling strategy to effectively utilize the abundance of unlabeled image data, thereby enhancing downstream tasks’ performance. In this paper, we propose Spatial Reasoning, a novel auxiliary pretraining method that takes advantage of a more flexible formulation of contrastive learning by introducing spatial reasoning as an auxiliary task for discriminative self-supervised methods. Spatial Reasoning works by having the network predict the relative distances between sampled non-overlapping patches. We argue that this forces the network to learn more detailed and intricate internal representations of the objects and the relationships between their constituting parts. Our experiments demonstrate substantial improvement in downstream performance in linear evaluation compared to similar work and provide directions for further research into spatial reasoning.
Introduction
Self-supervised learning (SSL) has emerged as a cornerstone of modern computer vision, enabling models to leverage vast quantities of unlabeled data. Current SSL approaches generally fall into two categories: generative methods, which focus on reconstructing missing image components, and discriminative methods, which learn to distinguish between different images or views.
While generative models, such as Vision Transformers, are highly effective, they often require significant computational resources. Conversely, discriminative models like ResNets are more efficient but frequently suffer from "local reasoning" issues. They may identify objects based on texture alone (e.g., elephant skin) without grasping the global spatial arrangement of parts (e.g., the relationship between a trunk and ears). To bridge this gap, we introduce Spatial Reasoning, an auxiliary task designed to teach models the internal spatial logic of objects.
Methodology
The proposed Spatial Reasoning method integrates an auxiliary task into a Relational Reasoning architecture. The process involves several key steps:
- Patch Generation: For a given image, the system extracts $N$ random, non-overlapping patches.
- Augmentation and Encoding: These patches undergo separate augmentations (such as color jittering and grayscaling) and are resized before being passed through an encoder.
- Dual Objective: A "relation module" processes the encoded patches with two goals:
- Binary Classification: Determining if a pair of patches originates from the same source image.
- Spatial Prediction: Predicting the relative $(x, y)$ distance between the two patches.
The core intuition is that to accurately predict that "Patch A is 20 pixels to the left of Patch B," the network must develop a deep understanding of the semantic content within those patches. This forces the model to learn how various parts of an object constitute the whole. To address inference speed, we also explored an "additive-patch-use" variant where patches are padded with zeros to match the original image size, allowing spatial feature learning without multiple forward passes during deployment.
Experimental Results
We evaluated Spatial Reasoning across several standard benchmarks, including CIFAR-10/100, tiny-ImageNet, and STL-10.
Performance Benchmarks
The method achieved state-of-the-art results among discriminative self-supervised methods:
- tiny-ImageNet: Reached 33.08% accuracy, a notable improvement over the 30.54% baseline.
- CIFAR-100: Improved performance to 50.18% (from 46.17%).
- STL-10: Achieved a high accuracy of 90.25%.
Cross-Domain Generalization
In transfer learning tasks (e.g., training on CIFAR-100 and testing on CIFAR-10), Spatial Reasoning achieved 75.8% accuracy. This represents a nearly 8% improvement over the baseline, suggesting that the learned spatial representations are significantly more generalizable than those learned through standard contrastive tasks.
Discussion and Insights
Our findings highlight several key aspects of spatial supervision:
- Dense Supervisory Signal: Relative distance provides a "free" and dense signal that is more informative than simple binary labels.
- Efficiency: Spatial Reasoning outperforms standard Relational Reasoning while using significantly fewer augmentations (4 vs. 16-32), drastically reducing training overhead.
- Patch Dynamics: We identified a "Goldilocks" zone for patch size; patches must be large enough to contain semantic meaning ($>20$ pixels) but small enough to keep the spatial task challenging.
- Shortcut Mitigation: By focusing on patches, the model is discouraged from relying on global shortcuts like color histograms, forcing it to learn structural features.
Conclusion
Spatial Reasoning offers a powerful yet efficient way to enhance the representational quality of discriminative SSL models. While the current implementation introduces some inference overhead (mitigated by the additive-patch variant), the gains in accuracy and generalizability are substantial. Future work will explore dynamic patch sampling and the integration of spatial reasoning into other frameworks like SimCLR or MoCo.
Summary updated