Learning Imbalanced Datasets with Label-Distribution-Aware Margin Loss

Kaidi Cao, Colin Wei, Adrien Gaidon, Nikos Aréchiga, Tengyu Ma

Abstract: Deep learning models often struggle with long-tailed data distributions, where majority classes dominate the training process. This paper proposes Label-Distribution-Aware Margin (LDAM) loss, which encourages larger margins for minority classes based on theoretical generalization bounds. Complementing this, a Deferred Re-Weighting (DRW) training schedule is introduced to decouple feature learning from classifier balancing. Experimental results on benchmarks like imbalanced CIFAR and iNaturalist 2018 demonstrate that LDAM-DRW significantly improves performance on rare classes while maintaining overall accuracy.

Introduction

In many practical applications, data is naturally imbalanced. For instance, in species classification, common species may have thousands of images, while rare ones have only a handful. Standard Empirical Risk Minimization (ERM) using Cross-Entropy loss prioritizes average accuracy, which often results in models that ignore the "long tail" of minority classes. While techniques like re-sampling and re-weighting exist, they frequently lead to overfitting on rare samples. This work addresses the challenge of improving generalization for minority classes without compromising performance on majority ones.

Methods

The proposed approach consists of two main components: a novel loss function and a strategic training schedule.

Label-Distribution-Aware Margin (LDAM) Loss

The core idea of LDAM is to provide more "breathing room" for minority classes. By deriving generalization bounds, the authors show that to achieve uniform test error across classes, the margin for a class $j$ should be inversely proportional to the number of its training samples $n_j$. Specifically, the margin is set proportional to $n_j^{-1/4}$.

Geometric interpretation of class-dependent margins. The minority class (green circles) is assigned a larger margin $\gamma_2$ compared to the majority class margin $\gamma_1$.

As shown in the figure above, this forces the decision boundary further away from the minority class data points, encouraging the model to learn more robust representations for rare categories rather than simply memorizing them.

Deferred Re-Weighting (DRW)

Re-weighting the loss function is a common strategy to handle imbalance, but applying it from the start of training can hinder the learning of high-quality features. The authors propose Deferred Re-Weighting (DRW), a two-stage training schedule. In the first stage, the model is trained using standard ERM to learn a strong feature extractor. In the second stage, re-weighting is introduced to fine-tune the decision boundaries. This "wait-and-see" approach ensures that the model develops a good visual understanding before attempting to balance the class-specific performance.

Experiments and Results

The effectiveness of LDAM-DRW was evaluated on several benchmarks, including imbalanced versions of CIFAR-10 and CIFAR-100, and the large-scale iNaturalist 2018 dataset.

Performance comparison on imbalanced CIFAR-10 and CIFAR-100 datasets across different imbalance types and ratios. LDAM-DRW consistently outperforms baselines.

On the iNaturalist 2018 dataset, which contains over 8,000 species with extreme natural imbalance, LDAM-DRW achieved a Top-1 error of 32.00%, a significant improvement over the standard ERM baseline (42.86%) and previous state-of-the-art methods like CB-Focal (38.88%).

Discussion and Conclusion

The success of LDAM-DRW highlights two key insights. First, the $n_j^{-1/4}$ margin provides a theoretical bridge between sample size and the required model confidence. Second, the separation of feature learning and classifier balancing via DRW prevents the distortion of early-stage feature representations.

While highly effective, the approach does have limitations. The margin calculation relies on "slow-rate" generalization bounds; for extremely large models, "fast-rate" bounds might be more suitable. Additionally, the method assumes some degree of linear separability in the feature space. Future work may explore adaptive margin constants and applications to datasets with high label noise.

By shifting from uniform treatment to distribution-aware margins, LDAM-DRW offers a robust and mathematically sound framework for tackling the pervasive problem of class imbalance in deep learning.

Summary updated

BibTeX
@inproceedings{cao2019learning,
  author = {Kaidi Cao and Colin Wei and Adrien Gaidon and Nikos Aréchiga and Tengyu Ma},
  title = {{Learning Imbalanced Datasets with Label-Distribution-Aware Margin Loss}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=875F8VPBhsT},
}
Figure