Class-Aware Contrastive Semi-Supervised Learning

Fan Yang, Kai Wu, Shuyi Zhang, Guannan Jiang, Yong Liu, Feng Zheng, Wei Zhang, Chengjie Wang, Long Zeng

Abstract

Class-Aware Contrastive Semi-Supervised Learning (CCSSL) is a novel "drop-in" module designed to address the "confirmation bias" problem inherent in semi-supervised learning. By intelligently separating in-distribution data from noisy out-of-distribution (OOD) samples, CCSSL applies distinct learning objectives: class-wise clustering for confident predictions and image-level contrastive learning for unconfident ones. This approach significantly boosts accuracy and convergence speed on both standard benchmarks and challenging real-world datasets, such as Semi-iNat 2021.

Addressing the Confirmation Bias in SSL

Semi-supervised learning (SSL) leverages a small amount of labeled data alongside a massive volume of unlabeled data. Most modern SSL methods rely on pseudo-labeling, where the model predicts labels for unlabeled images and treats those predictions as ground truth for further training.

However, this creates a "confirmation bias" loop. If the model makes an incorrect prediction and subsequently trains on that error, the mistake becomes entrenched. This problem is exacerbated in real-world scenarios where unlabeled data is "raw," often containing out-of-distribution (OOD) samples—images from classes the model has never seen. Standard SSL methods attempt to force these unknown images into known categories, leading to significant noise and potential model collapse.

Conceptual comparison of standard pseudo-labeling (b) versus the proposed Class-Aware Contrastive SSL (c).

The CCSSL Framework

The authors introduce CCSSL as a framework that can be added to existing SSL algorithms like FixMatch or CoMatch. Its core innovation is the Class-Aware Contrastive Module, which processes unlabeled data differently based on the model's confidence:

  1. Dynamic Data Separation: Using a confidence threshold ($T_{push}$), the model splits a batch of unlabeled data into high-confidence and low-confidence subsets.
  2. Class-Wise Clustering (In-Distribution): If the model is confident about a sample, CCSSL pulls that sample closer to others sharing the same pseudo-label in the feature space. This strengthens the model's ability to categorize known classes.
  3. Image-Wise Contrastive Learning (OOD): If the model is unconfident (likely OOD), it abandons class labels. Instead, it performs standard contrastive learning—pulling different augmented views of the same image together while pushing all other images away. This allows the model to learn useful features without being "tricked" by a faulty label.
  4. Target Re-weighting: To further reduce noise, the contrastive loss is weighted by the product of the confidence scores of the samples being compared, ensuring the model focuses on the most reliable data.

Experimental Evaluation

CCSSL was evaluated on a mix of controlled benchmarks (CIFAR-10, CIFAR-100, STL-10) and "wild" datasets like Semi-iNat 2021, which is characterized by extreme class imbalance and a high volume of OOD unlabeled data.

Performance Gains

The performance gains, especially on difficult datasets, are striking. On the Semi-iNat 2021 dataset, adding CCSSL to FixMatch improved Top-1 accuracy by 9.80% (from 21.41% to 31.21%). On CIFAR-100 with only 400 labels, CCSSL achieved 61.19% accuracy, outperforming the base FixMatch (51.15%) by over 10%.

Efficiency and Convergence

CCSSL also significantly improves training efficiency. Because it provides a more reliable training signal early in the process, models reach high accuracy levels much faster than standard SSL counterparts.

Training curves showing Top-1 Accuracy over epochs for MixMatch and FixMatch with and without CCSSL.

Conclusion

CCSSL demonstrates that contrastive learning can serve as an effective safety net in semi-supervised learning. By using image-level contrastive learning for low-confidence samples, the framework provides an unbiased training signal that does not depend on a potentially faulty classification head. While the module introduces new hyperparameters, its ability to handle OOD data and accelerate convergence makes it a powerful tool for practical SSL applications.

Summary updated

BibTeX
@inproceedings{yang2022class,
  author = {Fan Yang and Kai Wu and Shuyi Zhang and Guannan Jiang and Yong Liu and Feng Zheng and Wei Zhang and Chengjie Wang and Long Zeng},
  title = {{Class-Aware Contrastive Semi-Supervised Learning}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
}
Figure