Abstract
As one of the most effective self-supervised representation learning methods, contrastive learning (CL) relies on multiple negative pairs to contrast against each positive pair. In the standard practice of contrastive learning, data augmentation methods are utilized to generate both positive and negative pairs. While existing works have been focusing on improving the positive sampling, the negative sampling process is often overlooked. In fact, the generated negative samples are often polluted by positive samples, which leads to a biased loss and performance degradation. To correct the negative sampling bias, we propose a novel contrastive learning method named Positive-Unlabeled Contrastive Learning (PUCL). PUCL treats the generated negative samples as unlabeled samples and uses information from positive samples to correct bias in contrastive loss. We prove that the corrected loss used in PUCL only incurs a negligible bias compared to the unbiased contrastive loss. PUCL can be applied to general contrastive learning problems and outperforms state-of-the-art methods on various image and graph classification tasks.
Introduction
Self-supervised contrastive learning (CL) has emerged as a powerful paradigm for representation learning. It typically involves comparing a "positive" pair—often two augmented views of the same data point—against a pool of "negative" pairs. The objective is to minimize the distance between positive embeddings while maximizing the distance to negatives. However, a significant yet often ignored issue is "negative sampling bias." In standard CL, any random sample from the dataset is assumed to be a true negative. In reality, semantically similar items (e.g., two different images of dogs) may be accidentally paired as negatives. Forcing the model to push these similar items apart creates a biased loss that degrades representation quality.
Methodology
To address this, we introduce Positive-Unlabeled Contrastive Learning (PUCL). This method reframes the negative sampling problem through the lens of Positive-Unlabeled (PU) Learning. Instead of treating the negative pool as containing only true negatives, PUCL treats them as "unlabeled" samples—a mixture of both true negatives and potential false negatives (positives).
The PUCL framework leverages the "Selected Completely At Random" (SCAR) assumption to estimate the true negative distribution by mathematically "subtracting" the positive distribution's influence from the unlabeled pool. This leads to the $L_{DeCL}$ loss function, which modifies the standard Noise-Contrastive Estimation (NCE) denominator with a debiased term. This correction relies on two primary hyperparameters: the positive prior $\alpha$ and the label frequency $c$. Theoretically, we demonstrate (Theorem 1) that the bias in PUCL's corrected loss becomes negligible as the number of negative samples increases.
Experimental Setup
The efficacy of PUCL was evaluated across multiple domains:
- Image Classification: Benchmarks included CIFAR-10, CIFAR-100, and STL10, the latter containing 100,000 unlabeled images.
- Graph Classification: To test generalizability, we used datasets from the TU collection, including PTC, ENZYMES, DD, and REDDIT-BINARY.
Results and Discussion
PUCL demonstrates significant performance gains when integrated into established frameworks like SimCLR, MoCo, and CMC. For instance, on the STL10 dataset, adding PUCL to SimCLR increased classification accuracy from 80.50% to 85.62%. On CIFAR-100, MoCo + PUCL reached 71.21% accuracy, a substantial improvement over the 66.38% baseline.
Qualitative analysis via UMAP visualizations confirms that PUCL produces tighter, more semantically coherent clusters than competing debiasing methods like "Ring" or "Hard" sampling. Furthermore, the method's success on graph datasets—such as a 6% improvement on REDDIT-BINARY—highlights its broad applicability across different data modalities regardless of the underlying architecture.
Conclusion and Future Work
PUCL provides a mathematically grounded solution to the negative sampling bias in contrastive learning. While the method currently requires manual tuning of the positive prior $\alpha$ and label frequency $c$, it remains robust across various batch sizes. Future research will focus on automating the estimation of these hyperparameters to enable a fully end-to-end, self-tuning system for diverse datasets.
Summary updated