Stable Single-Pixel Contrastive Learning for Semantic and Geometric Tasks

Leonid Pogorelyuk, Niels Leif Bracher, Aaron Verkleeren, Lars Kühmichel, Stefan T. Radev

TL;DR

This paper presents a new, stable contrastive loss formulation for training neural networks to produce pixel-level, overcomplete feature embeddings (i.e., feature dimensions $D > 3$ per pixel). Unlike conventional contrastive methods that require momentum encoders or teacher–student dynamics to prevent representation collapse, this approach trains stably end-to-end and captures both fine geometric structures and semantic invariance across 2D transformations and 3D viewpoints.

What Problem Does This Paper Address?

Computer vision representations often divide along two lines:

  • Geometric models (e.g., optical flow, visual SLAM, SfM) prioritize sub-pixel spatial precision but typically ignore high-level semantic meaning.
  • Semantic models (e.g., ViTs, DINO, SAM) provide rich contextual understanding, but their patch-based tokenization or coarse feature downsampling leaves them too imprecise for fine point-matching.

Existing pixel-level contrastive representation methods usually rely on complex momentum-based moving averages (like MoCo-style teacher–student setups) to stabilize training. The authors aim to bridge the semantic–geometric divide by learning per-pixel descriptors that are simultaneously semantically invariant and geometrically precise, using a single, stable contrastive loss that trains without momentum updates.

Methods

The authors train a U-Net–style convolutional encoder–decoder (around 1M parameters) that maps an RGB image $I \in \mathbb{R}^{H \times W \times 3}$ to an overcomplete feature tensor $\mathcal{F}(I) \in \mathbb{R}^{H \times W \times D}$ (typically $D=32$).

Key components of the framework include:

  1. Within-Image Contrastive Loss ($\mathcal{L}_{\text{within}}$): Given two transformed views of the same scene with a known pixel-to-pixel coordinate mapping $\mathcal{T}(p)$:
  2. Positive pairs: $D_{\text{pos}}(p) = \|\mathcal{F}(I_1)(p) - \mathcal{F}(I_2)(\mathcal{T}(p))\|_p$
  3. Negative pairs: $D_{\text{neg}}(p) = \|\mathcal{F}(I_1)(p) - \mathcal{F}(I_2)(\mathcal{R}(p))\|_p$ (random coordinates $\mathcal{R}(p)$)
  4. The loss sums a linear and quadratic term: $\sum [-D_{\text{neg}} + D_{\text{neg}}^2]$ for negatives and $[D_{\text{pos}} + D_{\text{pos}}^2]$ for positives. The $-D$ pushes negatives apart, while the $+D^2$ prevents negative features from diverging unbounded.
  5. Between-Image Contrastive Loss ($\mathcal{L}_{\text{between}}$): Penalizes feature similarity across unrelated images at identical coordinates: $$\mathcal{L}_{\text{between}} = \frac{1}{|S|}\sum_{p \in S} [-C(p) + C(p)^2]$$

  6. Combined Objective: $$\mathcal{L}_{\text{total}} = \lambda \mathcal{L}_{\text{within}} + (1 - \lambda) \mathcal{L}_{\text{between}}$$

  7. Norm Selection: The distance norm $\|\cdot\|_p$ is systematically evaluated across $\ell_1$, $\ell_2$, and $\ell_\infty$.

Datasets

The authors evaluated their method in both 2D and 3D synthetic setups:

  • Colored MNIST (2D Domain Generalization): $28 \times 28$ grayscale digits resized to $32 \times 32$ with injected spurious background color correlations (correlation $p_{\text{train}} = 0.85$ in-distribution vs. $p_{\text{test}} = 0.10$ out-of-distribution). Label task: predict if digit is $\ge 5$ (with 25% label flip noise).
  • Synthetic 3D Scene Benchmark: 40,336 3D object meshes from ShapeNetCore positioned randomly in 76 room meshes from SceneNN. Ray tracing calculates exact 3D surface point correspondence and occlusion masks between randomized camera viewpoints.

Key Insights and Ideas

  • The $\ell_\infty$ norm induces discrete, bit-like descriptors: Using the $\ell_\infty$ Chebyshev norm enforces that non-matching pixels must differ by a margin in at least one feature channel. This forces channels to act like distinct binary switches (semantic masks or geometric edge detectors), whereas $\ell_1$ and $\ell_2$ produce continuous, blurry feature maps.
  • $\lambda = 1.0$ filters out spurious color: Setting $\lambda = 1$ (relying strictly on the within-image mapping loss across augmentations) completely discards background color and preserves shape semantics. Lowering $\lambda$ encourages the backbone to encode color differences, dropping out-of-distribution robustness.
  • Emergent segmentation and geometric edges: Without explicit supervision, some channels of the 3D-trained network specialize into object instance segmentation, while others specialize into surface interior versus shape edge locators in 3D space.

Key Results

  • Training Stability: Backbone training with $\ell_\infty$ and $\ell_1$ converges smoothly with low variance across random seeds, avoiding representation collapse without requiring an exponential moving average (EMA) teacher model.
  • Colored MNIST Generalization:
  • With $\lambda = 1.0$, frozen backbone features achieve the shape-only ceiling ($\approx 75\%$ accuracy on both ID and OOD splits), confirming pure shape encoding.
  • At lower $\lambda$ (e.g., $\lambda \le 0.5$), models often encode color, resulting in high ID accuracy ($\approx 85\%$) but collapsed OOD performance ($\approx 10\%$).
  • 3D Matching: In SceneNN + ShapeNet scenes, the learned per-pixel descriptors consistently track corresponding points across camera rotations, occlusions, and viewpoint changes.

Limitations and Future Work

  • Computational Cost: Learning high-dimensional, overcomplete descriptors ($D \gg 3$) for every pixel scales memory and compute consumption higher than bottlenecked or patch-level embeddings.
  • Simulation Gap: Training in 2D relies on synthetic perspective transforms and affine augmentations, which do not fully replicate complex real-world camera motions or lighting shifts.
  • Future Directions: The authors plan to evaluate real-world stereo imagery benchmarks with known ground-truth correspondence pairs to bridge the synthetic-to-real domain gap.

Summary updated

BibTeX
@inproceedings{pogorelyuk2025stable,
  author = {Leonid Pogorelyuk and Niels Leif Bracher and Aaron Verkleeren and Lars Kühmichel and Stefan T. Radev},
  title = {{Stable Single-Pixel Contrastive Learning for Semantic and Geometric Tasks}},
  booktitle = {UniReps @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=nzGuDABwce},
}
Figure