Learning to Perceive "Where": Spatial Pretext Tasks for Robust Self-Supervised Learning

Yang Shen, Yusen Cai, Weronika Hryniewska-Guzik, Qing Lin, Mengmi ZhangarXiv 2026

TL;DR

Modern self-supervised learning (SSL) methods are excellent at recognizing what an object is, but they often struggle to understand where its parts are located relative to one another. This paper introduces Spatial Prediction (SP), a simple, plug-and-play auxiliary task that forces models to predict the relative position and scale of two random image patches. Integrating SP into popular SSL frameworks like MAE, MoCo v3, and DINO consistently improves their spatial awareness, downstream performance, and out-of-distribution robustness.

What Problem Does This Paper Address?

Current self-supervised learning paradigms generally fall into two camps: invariance-based methods (like contrastive learning or self-distillation) and reconstruction-based methods (like Masked Autoencoders).

While highly effective, both approaches have a blind spot when it comes to geometry:

  • Invariance methods treat spatial transformations (like cropping and scaling) as nuisances to be ignored, training the network to output the same representation regardless of how a patch is altered.
  • Reconstruction methods operate on localized patches but lack a global coordinate system, meaning they fail to learn holistic, part-to-part geometric relationships.

As a result, these models often lack spatial grounding and over-rely on local textures rather than global object shapes and layouts. The authors tackle this by explicitly introducing spatial reasoning into the self-supervised pre-training phase.

Figure 1: Problem setting and task overview for visual representation learning from partial observations. The left panel illustrates the problem setting: two cropped and resized views (orange and blue) are sampled from the same image, and the SSL model predicts the relative position and scale of the orange patch with respect to the blue reference. The right panel summarizes the evaluation tasks for benchmarking SSL models. (a) Image recognition includes in-domain classification on C100 [1] and IN-1K [2], out-of-distribution robustness on IN-C [3], IN-R [4], Sketch [5], and Occlusion, and cross-dataset transfer learning on Flowers [6], C100 [1], DTD [7], and Food [8]. (b) Dense prediction tasks include semantic segmentation on PASCAL VOC [9] and depth estimation on NYU [10]. (c) Spatial prediction evaluates the ability of SSL models to estimate relative position and scale between two local views. (d) Jigsaw understanding evaluates patch reordering, reconstruction, and subsequent recognition. (c) and (d) correspond to our newly proposed benchmarks and tasks on IN-1K [2].

Methods

The authors propose Spatial Prediction (SP), a spatially aware pretext regression task designed as an architecture-agnostic plug-in.

The workflow consists of three main components:

  1. Curated View Sampling: To prevent the model from exploiting trivial shortcuts (like matching edge lines or color gradients), the authors use a rejection sampling strategy. It ensures that pairs of sampled patches have a non-trivial spatial displacement, sufficient semantic content, and a balanced, uniform distribution of relative positions and scales.
  2. Projection-Free Cross-Attention: Given a reference patch ($I_r$) and a target patch ($I_t$), both are passed through a shared Vision Transformer (ViT) encoder. The [CLS] token of the reference patch acts as a query to attend to the patch tokens of both views. Crucially, this cross-attention mechanism uses no additional learnable linear projections, forcing the model to rely entirely on raw token interactions.
  3. Continuous Regression: The retrieved features are concatenated and fed into a lightweight two-layer MLP that predicts the continuous relative offset $(\Delta x, \Delta y)$ and the relative scale ratio. The entire module is trained using a standard $\ell_2$ loss alongside the base SSL objective.
Figure 2: Overview of Spatial Prediction (SP). Given a reference view Ir and a target view It sampled from the same image, both views are encoded by a shared Vision Transformer (ViT) [50]. The class token ([CLS]) of the reference view serves as the query (Q), while patch tokens from both reference and target views act as keys (K) and values (V ) to compute a cross-attention-like interaction (⊗), producing reference and target features. This operation is parameter-free, as it directly uses token embeddings without additional projections for Q, K, and V . The resulting features Zr and Zt are concatenated and fed into a two-layer MLP to regress the relative position and scale, supervised using ℓ2 loss against ground-truth targets. As illustrated in the right panels, the ground-truth spatial relationship is defined by the relative offset (∆x, ∆y) from the reference view to the target view, along with the relative scale normalized by the reference view dimensions (Hr, Wr), where (Hr, Wr) and (Ht, Wt) denote the height and width of the reference and target views, respectively.

Datasets

The models were pre-trained on CIFAR-100 and ImageNet-1K. To evaluate the representations, the authors utilized a diverse suite of downstream datasets:

  • Robustness & OOD: ImageNet-C (corruptions), ImageNet-R (renditions), ImageNet-Sketch, and a custom ImageNet-Occlusion benchmark.
  • Transfer Learning: Flowers-102, DTD (textures), and Food-101.
  • Dense Prediction: PASCAL VOC (semantic segmentation) and NYU v2 (depth estimation).

Additionally, the authors introduced two new diagnostic benchmarks derived from the ImageNet-1K test set to specifically probe spatial reasoning:

  • Spatial Prediction Task: Directly measures a model's accuracy in predicting the relative geometry of patch pairs.
  • Jigsaw Understanding Task: Requires the model to correctly reorder a shuffled $3 \times 3$ grid of image patches and recognize the object within the reconstructed image.

Key Insights and Ideas

  • Spatial Awareness Enhances Semantics: Explicitly forcing a network to learn geometry does not dilute its semantic understanding. Instead, it yields sharper, more object-centric attention maps. Rather than scattering attention across background contexts, SP-trained models focus tightly on the actual boundaries of objects.
  • Mitigating Texture Bias: Standard SSL models are notoriously biased toward textures. By forcing the network to reason about how parts assemble into wholes, SP injects a structural inductive bias that shifts the model's focus toward global object layouts and shapes.
  • Simplicity Wins: In ablation studies, adding learnable projections to the cross-attention block actually degraded performance. Preserving raw token interactions while enforcing structured cross-view attention proved to be the most effective strategy for learning spatial relationships.

Key Results

Integrating SP yielded substantial quantitative improvements across all evaluated base frameworks (MAE, MoCo v3, DINO):

  • ImageNet-1K Classification: MAE + SP achieved a massive +8.0% boost in Top-1 accuracy (jumping from 44.6% to 52.6%), while MoCo v3 + SP saw a +5.0% improvement.
  • Out-of-Distribution Robustness: On the ImageNet-Occlusion benchmark, MAE + SP improved accuracy from 36.7% to 41.6%, proving that geometric awareness helps models infer missing visual information.
  • Diagnostic Spatial Tasks: On the challenging Jigsaw Understanding task, MoCo v3 + SP boosted permutation ordering accuracy from 69.87% to 90.24%, demonstrating a vastly superior grasp of global spatial configurations.
Figure 3: Example visualizations of learned representations by SSL models with and without SP. (a) Qualitative comparison of spatial attention maps. Following [31], we visualize attention by computing the attention weights between the classification token z and all patch tokens Z, reshaping them into a 2D spatial map, and upsampling to the input image size. Each row corresponds to an input image, and columns show attention maps overlaid on the images for MAE and DINO, with and without SP. Heatmaps are normalized to [0,1]; see the colorbar for scale. (b) Qualitative comparison of spatial reasoning results. Predicted relative positions and scales between two local views are visualized on the original image. Each row corresponds to an input image, and columns show results for MAE and DINO, with and without SP. Blue boxes denote reference views, red boxes denote predicted positions and scales, and green dashed boxes denote ground truth; arrows indicate predicted (red) and ground-truth (green) displacement vectors. See Fig. S3 for examples on MoCo v3.

Limitations and Future Work

While SP demonstrates clear benefits, the authors note that it is currently restricted to 2D image space. It does not explicitly model 3D spatial geometry or temporal constraints (such as tracking object parts across video frames). The authors suggest that extending this geometric regression framework to 3D environments and video domains is a promising next step for developing more capable vision foundation models in robotics and embodied AI.

Summary updated

BibTeX
@misc{shen2026learning,
  author = {Yang Shen and Yusen Cai and Weronika Hryniewska-Guzik and Qing Lin and Mengmi Zhang},
  title = {{Learning to Perceive "Where": Spatial Pretext Tasks for Robust Self-Supervised Learning}},
  year = {2026},
  eprint = {2605.09963},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.09963},
}
Figure