Most machine learning breakthroughs rely on "curated" datasets where classes are roughly balanced, such as ImageNet-1k. However, data "in the wild" is almost always imbalanced, typically following a long-tailed distribution where a few classes have many examples and most have very few.
While it is well-documented that supervised learning (SL) performs poorly on such data—often ignoring the "tail" to over-optimize for the "head"—the behavior of self-supervised learning (SSL) in these scenarios has been less clear. Since SSL is designed to work without labels, it is the natural candidate for training on massive, uncurated web data. This paper systematically investigates whether SSL inherits the same weaknesses as SL when faced with dataset imbalance, and proposes a novel method to further improve its robustness.
The Challenge of Imbalanced Data
The authors approach the problem by systematically comparing SSL methods (MoCo v2, SimSiam) against supervised pre-training across various imbalance ratios and dataset sizes. They evaluate both In-Domain (ID) performance (linear probing on the same distribution) and Out-of-Domain (OOD) performance (fine-tuning on different datasets like STL-10, CUB-200, Stanford Cars, Oxford Pets, and FGVC Aircraft).
To mimic natural data distributions, the study utilizes long-tailed versions of CIFAR-10 and ImageNet (ImageNet-LT), created using exponential and Pareto distributions.
Empirical Findings
The empirical benchmarking reveals a striking conclusion: the performance gap between training on balanced versus imbalanced data is much smaller for SSL than for SL.
On ImageNet, the relative performance drop caused by imbalance is significantly lower for SSL (MoCo v2) than for supervised learning across all tested sample sizes. This holds true for in-domain evaluations, but the advantage becomes even more pronounced in out-of-domain tasks. In many OOD scenarios, SSL trained on imbalanced data actually outperforms SL trained on perfectly balanced data.
Why is SSL "Accidentally" Robust?
To understand why SSL is more robust, the authors constructed a mathematical model and designed semi-synthetic experiments. Their findings suggest that supervised learning is inherently "lazy." It only learns the specific features necessary to distinguish between the provided labels. If a feature isn't needed to tell a "head" class apart, SL simply ignores it.
SSL, on the other hand, has no labels to guide it. It is forced to learn everything that makes an image unique to successfully contrast it with others. This results in a richer, more diverse feature set that "accidentally" includes features useful for the rare tail classes.
Crucially, features learned from frequent classes in SSL are often label-irrelevant but transferable. For example, learning the detailed texture of a common dog breed helps the model represent a rare wolf species later on. A supervised model might have ignored those textures entirely, focusing only on simple shape cues sufficient to classify the common dog.
Closing the Gap with rwSAM
Building on these insights, the authors propose an algorithmic improvement: Reweighted Sharpness-Aware Minimization (rwSAM). Because rare examples are more prone to overfitting, rwSAM introduces a label-free regularization technique designed specifically for long-tailed data.
The method works by:
- Using Kernel Density Estimation (KDE) in the representation space to estimate sample frequency without needing any labels.
- Applying a stronger "sharpness-based" regularization (SAM) specifically to samples in low-density regions (the rare tail classes) to improve their generalization.
On CIFAR-10-LT, rwSAM improved the SimSiam baseline by over 1%, remarkably surpassing the performance of a model trained on a perfectly balanced dataset of the exact same size. Furthermore, rwSAM consistently improved transfer learning results on downstream tasks like CUB-200 and Stanford Cars, effectively closing the "imbalance gap" by focusing regularization where it is needed most.
Limitations and Future Work
While the findings are highly promising, the authors note a few limitations:
- Domain Scope: The study primarily focuses on computer vision and convolutional neural networks (ResNets). Future work should investigate if these robustness properties hold for Natural Language Processing (NLP) and Transformer architectures.
- Computational Cost: The density estimation step (KDE) required for rwSAM adds computational overhead, although this is mitigated by using a subset of the data for the estimation.
- Extreme Imbalance: While SSL is more robust than SL, it is not entirely immune. Extremely high imbalance ratios still degrade representation quality, indicating that there is still room for specialized SSL loss functions explicitly designed to handle the extreme tail of data distributions.
Summary updated