[Paper Review] Supervised Contrastive Learning with Hard Negative Samples
This paper proposes Hard-Negative Supervised Contrastive Learning (H-SCL), a contrastive learning framework that combines label information with hard-negative sampling to improve representation learning. H-SCL outperforms both SCL and H-UCL on image benchmarks, and theoretically bounds H-SCL loss by H-UCL loss, explaining H-UCL's empirical superiority over UCL.
Through minimization of an appropriate loss function such as the InfoNCE loss, contrastive learning (CL) learns a useful representation function by pulling positive samples close to each other while pushing negative samples far apart in the embedding space. The positive samples are typically created using "label-preserving" augmentations, i.e., domain-specific transformations of a given datum or anchor. In absence of class information, in unsupervised CL (UCL), the negative samples are typically chosen randomly and independently of the anchor from a preset negative sampling distribution over the entire dataset. This leads to class-collisions in UCL. Supervised CL (SCL), avoids this class collision by conditioning the negative sampling distribution to samples having labels different from that of the anchor. In hard-UCL (H-UCL), which has been shown to be an effective method to further enhance UCL, the negative sampling distribution is conditionally tilted, by means of a hardening function, towards samples that are closer to the anchor. Motivated by this, in this paper we propose hard-SCL (H-SCL) {wherein} the class conditional negative sampling distribution {is tilted} via a hardening function. Our simulation results confirm the utility of H-SCL over SCL with significant performance gains {in downstream classification tasks.} Analytically, we show that {in the} limit of infinite negative samples per anchor and a suitable assumption, the {H-SCL loss} is upper bounded by the {H-UCL loss}, thereby justifying the utility of H-UCL {for controlling} the H-SCL loss in the absence of label information. Through experiments on several datasets, we verify the assumption as well as the claimed inequality between H-UCL and H-SCL losses. We also provide a plausible scenario where H-SCL loss is lower bounded by UCL loss, indicating the limited utility of UCL in controlling the H-SCL loss.
Motivation & Objective
- To address the gap in performance between standard supervised contrastive learning (SCL) and hard-negative unsupervised contrastive learning (H-UCL), despite H-UCL's empirical superiority.
- To develop a unified framework that integrates label information and hard-negative sampling for improved representation learning.
- To theoretically justify why H-UCL outperforms UCL by showing that the H-SCL loss is bounded by the H-UCL loss but not by the UCL loss.
- To provide a clear, unified comparison of UCL, H-UCL, SCL, and H-SCL, clarifying their relationships and distinctions.
Proposed method
- Proposes H-SCL, a contrastive learning objective that uses class labels to define positive pairs and selects hard negatives based on embedding similarity.
- Introduces a temperature-scaled contrastive loss with a hardness parameter β to weight hard negatives more heavily.
- Employs a standard ResNet-50 backbone with a 128-dimensional projection head for representation learning.
- Uses a batch-based approximation of the negative sampling distribution, where negative samples are selected from the current mini-batch.
- Applies a grid search over β ∈ {0.1, 0.5, 1, 2, 5} to tune the hardness weighting in the loss function.
- Fixes the representation function after pre-training and evaluates performance via a linear classifier head.
Experimental results
Research questions
- RQ1Can combining label information with hard-negative sampling improve contrastive learning performance beyond standard SCL and H-UCL?
- RQ2Is there a theoretical relationship between the H-SCL loss and the H-UCL loss that explains H-UCL’s empirical success?
- RQ3Does the H-SCL objective provide a better proxy for minimizing the H-SCL loss than the UCL objective?
- RQ4How does the hardness parameter β affect the optimization and generalization of the H-SCL framework?
Key findings
- H-SCL achieves 75.11% top-1 accuracy on CIFAR100, outperforming SCL (71.68%) and H-UCL (67.77%) by over 3 percentage points.
- On STL10, H-SCL reaches 72.52% accuracy, a 4.24% improvement over SCL and 4.70% over H-UCL.
- H-SCL reaches the performance of SCL at 200 epochs in less than 50 epochs, indicating faster convergence.
- Theoretical analysis confirms that the H-SCL loss is bounded by the H-UCL loss under certain conditions, but not by the UCL loss.
- Empirical results in Figure 4 show that H-SCL loss is always upper-bounded by H-UCL loss across different β values, validating the theoretical bound.
- The average LHS of the key inequality (17) is 1.44, significantly larger than the RHS average of 0.99, supporting Assumption 1.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.