Generalized Parametric Contrastive Learning

Jiequan Cui, Zhisheng Zhong, Zhuotao Tian, Shu Liu, Bei Yu, Jiaya Jia

TL;DR

The authors introduce PaCo (and its simplified version GPaCo), a contrastive learning framework that fixes the "head-class bias" in long-tailed datasets by introducing learnable class centers. It achieves state-of-the-art results in long-tailed recognition and significantly boosts the out-of-distribution (OOD) robustness of models trained on balanced data like ImageNet.

What Problem Does This Paper Address?

In the real world, data is rarely balanced. Most datasets follow a long-tailed distribution, where a few "head" classes have thousands of examples, while many "tail" classes have only a handful.

Standard Supervised Contrastive Learning (SupCon)—which pulls samples of the same class together and pushes different classes apart—fails in this scenario. The authors' theoretical analysis reveals why: SupCon tends to focus its optimization efforts on high-frequency classes. Specifically, the gradient norm (the "signal" for learning) for frequent classes is much steeper than for rare ones, causing the model to ignore the tail. This leads to poor generalization on rare categories and a biased feature space.

Methods

The authors propose Parametric Contrastive Learning (PaCo) to rebalance the learning process.

  1. Parametric Class Centers: Unlike standard contrastive learning which only compares samples to other samples in a mini-batch or queue, PaCo introduces a set of learnable class-wise centers. Each class has a representative vector in the feature space that is updated during training.
  2. Rebalanced Loss: By pulling samples toward these parametric centers (in addition to other samples), the authors mathematically prove that the optimal probability of a "true positive" pair becomes more uniform across all classes, regardless of their frequency.
  3. Center Learning Rebalance: They incorporate "Balanced Softmax" into the center-related part of the loss to further moderate the influence of head classes.
  4. GPaCo (Generalized PaCo): Through ablation studies, the authors discovered that the momentum encoder (a staple in self-supervised methods like MoCo) actually hindered performance in this supervised setting. Removing it resulted in GPaCo, which is simpler, faster, and more robust.

Datasets

The researchers evaluated their method across a wide array of benchmarks:

  • Long-tailed Recognition: ImageNet-LT, Places-LT, CIFAR-100-LT, and the massive iNaturalist 2018.
  • Balanced Classification: Full ImageNet and CIFAR-100.
  • Robustness Benchmarks: ImageNet-C (corruptions), ImageNet-R (renditions), and ImageNet-S (sketches).
  • Semantic Segmentation: ADE20K, COCO-Stuff, PASCAL Context, and Cityscapes.

Key Insights and Ideas

  • The Gradient Gap: The paper visualizes that in standard SupCon, the gradient norm for the top 200 classes is dramatically higher than for the rest. PaCo flattens this curve, ensuring tail classes provide a meaningful training signal.
  • Adaptive Hard Example Mining: On balanced data, PaCo acts as an adaptive intensifier. As samples cluster more tightly around their class centers, the loss naturally increases the "pushing" force, forcing the model to focus on harder, more ambiguous examples.
  • The Momentum Encoder Paradox: In self-supervised learning, momentum encoders prevent "collapsing" solutions. However, in supervised learning with parametric centers, the centers themselves provide enough structure. The authors found that the strong regularization of a momentum encoder was actually detrimental to final accuracy.
  • Versatility: While designed for classification, GPaCo treats every pixel as an example, making it highly effective as an auxiliary loss for semantic segmentation.

Key Results

  • Long-Tailed SOTA: On ImageNet-LT, GPaCo (ResNet-50) achieved 58.5% top-1 accuracy, significantly outperforming previous leaders like RIDE (54.9%) and Balanced Softmax (55.0%).
  • iNaturalist 2018: Reached 75.4% accuracy, a new record for a ResNet-50 backbone.
  • Robustness: A ViT-B model trained with GPaCo on full ImageNet showed much better OOD robustness than models trained with MAE (Masked Autoencoders). For example, on ImageNet-S (Sketch), GPaCo improved accuracy by +3.3% over the baseline.
  • Segmentation: Adding GPaCo as an auxiliary loss provided a consistent boost of +1.0 to +1.5 mIoU across various Swin Transformer backbones on the ADE20K dataset.

Limitations and Future Work

  • Theoretical Gap: While the authors provide a strong theoretical motivation for the rebalancing effect of the centers, they acknowledge that a full theoretical analysis of integrating Balanced Softmax into the parametric center learning remains for future work.
  • Computational Overhead: For semantic segmentation, the number of pixels is too high to process all of them via contrastive loss. The authors currently use a random sampling strategy (8192 pixels per image), but more sophisticated sampling might yield even better results.

Summary updated

BibTeX
@article{cui2024generalized,
  author = {Jiequan Cui and Zhisheng Zhong and Zhuotao Tian and Shu Liu and Bei Yu and Jiaya Jia},
  title = {{Generalized Parametric Contrastive Learning}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2024},
  doi = {10.1109/tpami.2023.3278694},
}
Figure