Class Rectification Hard Mining for Imbalanced Deep Learning

Qi Dong, Shaogang Gong, Xiatian Zhu

Abstract

Deep learning models often struggle with extreme class imbalance, where majority classes dominate the training process at the expense of rare but critical attributes. This paper proposes Class Rectification Loss (CRL), a novel regularizer that performs incremental hard mining of minority class samples within each training batch. By focusing on difficult samples and visually similar negatives, CRL enables models to learn precise boundaries for sparsely sampled classes without the computational burden of global clustering or the overfitting risks of traditional re-sampling.

Introduction: The Challenge of Imbalanced Data

In real-world applications such as facial attribute recognition and clothing classification, data distributions typically follow a power law. For instance, in the X-Domain clothing dataset, the ratio between the most frequent and least frequent attributes can reach a staggering 1:4,162. Standard Convolutional Neural Networks (CNNs) tend to become biased toward majority classes, leading to poor sensitivity for minority attributes.

Long-tail distribution of attributes in X-domain and CelebA datasets.

Existing solutions like over-sampling often lead to overfitting, while cost-sensitive weighting can be unstable. More complex methods, such as Large Margin Local Embedding (LMLE), require expensive offline clustering that does not scale well to millions of images.

Methodology: Class Rectification Loss (CRL)

The proposed CRL framework integrates a standard cross-entropy loss with a targeted rectification mechanism. Unlike previous methods that attempt to model the local structure of all classes, CRL specifically targets minority classes identified during each training iteration.

Overview of the Class Rectification Loss (CRL) framework.

The process involves three key steps:

  1. Batch Profiling: Identifying minority classes within a training batch (those contributing to less than 50% of the batch).
  2. Minority Hard Mining: Searching for "hard positives" (misclassified minority samples) and "hard negatives" (visually similar samples from other classes).
  3. Loss Formulation: Using a relative comparison (triplet-based) approach to ensure hard positives are pulled closer to an anchor while hard negatives are pushed away.

This incremental, batch-wise learning allows the model to gradually discover and expand the boundaries of rare classes efficiently.

Experimental Results

The model was evaluated on the CelebA and X-Domain benchmarks. CRL demonstrated significant improvements, particularly as the imbalance ratio increased. For rare attributes like "Mustache" or "Blurry" in CelebA, CRL improved accuracy by over 20% compared to baseline models.

Beyond accuracy, CRL offers a massive computational advantage. It achieved an 11x speedup in training time compared to LMLE (approximately 30 hours versus 388 hours), making it highly suitable for large-scale industrial applications.

Conclusion

Class Rectification Loss provides a scalable and effective solution for extreme class imbalance in deep learning. By focusing on the most informative minority samples during training, it achieves state-of-the-art performance with significantly lower computational overhead. Future research will explore handling "zero-shot" attributes and modeling inter-attribute correlations.

Summary updated

BibTeX
@inproceedings{dong2017class,
  author = {Qi Dong and Shaogang Gong and Xiatian Zhu},
  title = {{Class Rectification Hard Mining for Imbalanced Deep Learning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2017},
  doi = {10.1109/iccv.2017.205},
}
Figure