Abstract
The deep convolutional neural network (CNN) has significantly raised the performance of image classification and face recognition. Softmax is usually used as supervision, but it only penalizes the classification loss. In this paper, we propose a novel auxiliary supervision signal called contrastive-center loss, which can further enhance the discriminative power of the features, for it learns a class center for each class. The proposed contrastive-center loss simultaneously considers intra-class compactness and inter-class separability, by penalizing the contrastive values between: (1) the distances of training samples to their corresponding class centers, and (2) the sum of the distances of training samples to their non-corresponding class centers. Experiments on different datasets demonstrate the effectiveness of contrastive-center loss.
Introduction
In deep learning for classification and face recognition, the standard Softmax loss is excellent at separating classes, but it doesn't explicitly encourage "compactness." This means features belonging to the same class can be spread out widely in the feature space, making the model less robust to intra-class variations.
Previous attempts to address this include:
- Contrastive and Triplet Losses: These work well but require complex "mining" strategies to find informative pairs or triplets of images, which is computationally expensive ($O(N^2)$ or $O(N^3)$ complexity).
- Center Loss: A breakthrough that learned a "center" for each class and pulled samples toward it. However, it only focused on intra-class compactness and ignored inter-class separability. If class centers start too close together, Center Loss does little to push them apart.
Methodology: Contrastive-Center Loss
The authors propose Contrastive-center loss ($L_{ct-c}$) as an auxiliary training signal. Unlike Center Loss, which only minimizes the distance to the correct center, this new loss function optimizes a ratio:
- The Numerator: The squared distance between a sample and its corresponding class center (encouraging compactness).
- The Denominator: The sum of squared distances between that same sample and all other class centers (encouraging separability).
By minimizing this ratio, the network is forced to pull samples toward their own center while simultaneously pushing them away from the "territory" of other classes. The total loss function is defined as $L = L_{softmax} + \lambda L_{ct-c}$, where $\lambda$ is a hyperparameter controlling the weight of the feature distribution. Class centers are updated during training using a mini-batch approach, similar to network weights.
Key Insights and Geometric Intuition
The power of the ratio approach lies in its sensitivity to the relative geometry of the feature space. It prevents the "lazy" convergence seen in standard Center Loss where classes might remain bunched together. Crucially, no complex data mining is required; because the loss uses all class centers in every calculation, training is simpler and more stable than triplet-based methods.
As seen in the visualization above, while Softmax makes classes "separable," Contrastive-center loss transforms them into distinct, compact "clusters." The average distance between class centers increased by 3.3 to 5 times compared to standard Center Loss.
Experimental Results
The proposed loss consistently outperformed both standard Softmax and the original Center Loss across several benchmarks:
- MNIST: Achieved 99.17% accuracy, compared to 98.8% (Softmax) and 98.94% (Center Loss).
- CIFAR-10: Using a 20-layer ResNet, it reached 92.45% accuracy, a 1.2% improvement over Softmax alone.
- LFW (Face Recognition): Achieved a verification accuracy of 98.68%. When compared to a model trained with standard Center Loss on the same architecture, it provided a 0.13% boost, proving its effectiveness in high-dimensional recognition tasks.
Discussion and Limitations
While effective, the model introduces hyperparameters like $\lambda$ (loss weight) and $\alpha$ (center learning rate), which require tuning. Additionally, maintaining $k$ class centers in memory could become a bottleneck for datasets with millions of classes, such as massive-scale face recognition. However, the contrastive term significantly helps mitigate issues related to poor center initialization, making the overall training process more robust.
Summary updated