NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sharpness & Shift-Aware Self-Supervised Learning

Ngoc N. Tran, Son Duong, Hoang Phan, Tung Pham, Dinh Q. Phung, Trung LearXiv 2023

Abstract

Self-supervised learning aims to extract meaningful features from unlabeled data for further downstream tasks. In this paper, we consider classification as a downstream task in phase 2 and develop rigorous theories to realize the factors that implicitly influence the general loss of this classification task. Our theories signify that sharpness-aware feature extractors benefit the classification task in phase 2 and the existing data shift between the ideal and practical distributions to generate positive pairs also remarkably affects this classification task. Further harvesting these theoretical findings, we propose to minimize the sharpness of the feature extractor and a new Fourier-based data augmentation technique to relieve the data shift in the distributions generating positive pairs, reaching Sharpness & Shift-Aware Contrastive Learning (SSA-CLR). We conduct extensive experiments to verify our theoretical findings and demonstrate that sharpness & shift-aware contrastive learning can remarkably boost the performance as well as obtaining more robust extracted features compared with the baselines.

Introduction

Self-supervised learning (SSL) has revolutionized vision model training by enabling the learning of powerful representations from vast amounts of unlabeled data. However, a persistent gap remains between pre-text training tasks and downstream classification. Most contrastive learning methods, such as SimCLR, rely on creating augmented "views" of a single image to form positive pairs. This approach faces two major hurdles identified by the authors: the Sharpness Gap and the Distribution Shift.

The authors provide theoretical evidence that "flat" minima in the loss landscape, which are known to improve generalization in supervised learning, also directly benefit the transition from unsupervised pre-training to downstream tasks. Furthermore, while ideal positive pairs should represent different instances of the same class, practical implementations use two versions of the same image. This creates a distribution shift that limits the model's ability to learn true category boundaries.

Methods: SSA-CLR

The proposed Sharpness & Shift-Aware Contrastive Learning (SSA-CLR) framework addresses these hurdles through two primary components: Sharpness-Aware Optimization and Fourier-Based Data Augmentation.

Sharpness-Aware Optimization

Building on the concept of Sharpness-Aware Minimization (SAM), SSA-CLR modifies the InfoNCE loss to seek regions of consistently low loss rather than just a single minimum. This is implemented via a gradient ascent step to find a "sharp" nearby point, followed by a descent step to flatten that region, thereby improving the model's generalization capabilities.

Fourier-Based Data Augmentation

To mitigate distribution shift without requiring labels, SSA-CLR utilizes frequency domain manipulation. In a Fourier Transform, the phase component typically carries structural information ("what"), while the amplitude carries style and background information ("where").

Fourier-based data augmentation: mixing the phase of an original image with the amplitude of a background image to simulate class-level diversity.

For a given image, the model identifies a similar image in the current batch and interpolates its amplitude with the original's phase. As shown in Figure 1, this creates a new positive example that retains the object's identity but places it in a class-relevant background context, effectively simulating class-level diversity.

Experimental Evaluation

The researchers evaluated SSA-CLR on standard computer vision benchmarks including CIFAR-10, CIFAR-100, Tiny-ImageNet, and STL-10.

Key Results

SSA-CLR consistently outperformed baselines like SimCLR and Hard-Negative CLR across several metrics:

  • Accuracy Boost: On CIFAR-100, SSA-CLR achieved a 71.90% Top-1 accuracy, representing a significant 4% improvement over standard SimCLR.
  • Robustness: The model demonstrated superior resilience to adversarial attacks. Under an FGSM attack on CIFAR-10, SSA-CLR maintained 69.47% accuracy, while SimCLR plummeted to 64.15%.
  • Feature Quality: t-SNE visualizations confirm that SSA-CLR produces much tighter and more distinct class clusters compared to standard contrastive methods.
t-SNE visualizations comparing SimCLR (left) and SSA-CLR (right), showing tighter and more distinct class clusters in the latter.

Conclusion

SSA-CLR bridges the gap between self-supervised pre-training and downstream performance by enforcing loss landscape flatness and addressing sampling distribution shifts. While sharpness-aware optimization introduces some computational overhead due to extra gradient calculations, the significant gains in accuracy and robustness justify the cost. Future work may explore alternative methods to combat distribution shifts beyond Fourier transforms, potentially utilizing generative modeling to create even more diverse positive pairs.

Summary updated

BibTeX
@misc{tran2023sharpness,
  author = {Ngoc N. Tran and Son Duong and Hoang Phan and Tung Pham and Dinh Q. Phung and Trung Le},
  title = {{Sharpness \& Shift-Aware Self-Supervised Learning}},
  year = {2023},
  eprint = {2305.10252},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.10252},
}
Figure