Learning to Generalize One Sample at a Time with Self-Supervision

Antonio D'Innocente, Silvia Bucci, Barbara Caputo, Tatiana TommasiarXiv 2019

Introduction

Deep learning models often struggle when the data they encounter at test time (the "target domain") differs from their training data (the "source domain"). This "domain shift" is a major hurdle for real-world deployment. While Domain Adaptation (DA) and Domain Generalization (DG) offer solutions, they typically require large batches of unlabeled target data or specific domain labels during training. This paper introduces a more flexible approach: Generalize One Sample at a time (GeOS). By leveraging self-supervised learning—specifically solving jigsaw puzzles—the model can adapt to a new environment using just a single unlabeled test image.

Methodology: Architecture and Self-Supervision

The core idea is to combine a primary classification task with a self-supervised auxiliary task. The authors chose the "Jigsaw Puzzle" task, where an image is divided into a $3 \times 3$ grid, shuffled, and the network must predict the original permutation. This forces the model to learn structural and spatial regularities that are more robust across domains than superficial features like color or texture.

The proposed architecture combines a primary classification loss with a self-supervised auxiliary loss, using a specific gradient backpropagation policy to prevent task interference.

To implement this, the researchers designed a Residual Auxiliary Block. Features from the main backbone are processed by an auxiliary module, and the result is added back to the primary flow. Crucially, they employ a tailored backpropagation policy: gradients from the auxiliary loss do not flow into the final layers of the primary classification network. This ensures that while the auxiliary task helps regularize the internal representations, it doesn't degrade the final classification logic.

The GeOS Strategy: Test-Time Adaptation

The standout innovation is the GeOS strategy. When a single test image arrives, the model doesn't just perform a forward pass. Instead, it creates multiple shuffled versions of that specific image and runs a few iterations of Gradient Descent to minimize the jigsaw loss.

The GeOS strategy allows the model to fine-tune its internal representations on a single unlabeled test image before making a final prediction.

This "one-sample learning" warms up the auxiliary block to the visual style of the new domain. By the time the final prediction is made, the model's internal features have been slightly adjusted to better handle the specific characteristics of the test sample.

Experimental Results

The method was evaluated on three major benchmarks:

  • PACS: On this standard DG/DA dataset (Photo, Art, Cartoon, Sketch), GeOS achieved an average accuracy of 81.88%, setting a new state-of-the-art.
  • CompCars: In predictive domain adaptation (cars over 11 years), the method showed significant robustness to temporal shifts.
  • Portraits: For gender classification across decades (1905–2013), the self-supervised approach matched or outperformed methods requiring extensive domain metadata.

Conclusion and Future Work

By treating self-supervision as a universal regularizer and enabling adaptation on a per-sample basis, GeOS significantly reduces the need for human-annotated metadata. While the current implementation introduces inference latency due to the test-time optimization, it demonstrates that a single image contains enough structural information to bridge the domain gap. Future work will likely focus on improving the efficiency of this adaptation process and exploring other pretext tasks.

Summary updated

BibTeX
@misc{dinnocente2019learning,
  author = {Antonio D'Innocente and Silvia Bucci and Barbara Caputo and Tatiana Tommasi},
  title = {{Learning to Generalize One Sample at a Time with Self-Supervision}},
  year = {2019},
  eprint = {1910.03915},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.03915},
}
Figure