Class-Balanced Loss Based on Effective Number of Samples
Yin CuiMenglin JiaTsung-Yi LinYang SongSerge J. Belongie
Develops a theoretically grounded loss re-weighting method based on the effective number of samples that captures diminishing data returns to significantly improve classification accuracy on long-tailed visual recognition benchmarks.
Real-world visual recognition datasets often follow long-tailed distributions, in which a small number of classes account for most examples while the majority of classes are represented by far fewer samples. Convolutional neural networks trained on such data typically perform poorly on the under-represented classes, limiting their usefulness for applications that rely on fine-grained or diverse categories.
The work develops a class-balanced loss that re-weights training examples according to an effective number of samples per class rather than raw class frequency. The authors first introduce a theoretical model that treats data sampling as a simplified random-covering process: each sample occupies a small neighboring region in feature space, and successive samples may overlap completely with previously seen data. This leads to a closed-form expression for the effective number of samples, (1 − β^n)/(1 − β), where n is the observed count for a class and β is a single hyper-parameter that controls the rate at which additional samples cease to add new information. The resulting weighting factor is then inserted into standard loss functions—softmax cross-entropy, sigmoid cross-entropy, and focal loss—producing a model- and loss-agnostic class-balanced term.
Extensive experiments were performed on artificially long-tailed versions of CIFAR-10 and CIFAR-100 (imbalance factors 10–200), the large-scale iNaturalist 2017 and 2018 datasets (more than 5 000 and 8 000 classes, respectively), and the relatively balanced ILSVRC 2012 benchmark. Networks were trained from scratch with ResNet architectures of varying depth, and performance was measured by top-1 and top-5 classification error.
Across these benchmarks the class-balanced losses consistently outperform their unweighted counterparts. On long-tailed CIFAR the best configurations reduce error by 3–8 percentage points relative to plain softmax or focal loss; on iNaturalist the gains exceed 3–4 points for ResNet-50 and allow a 50-layer network trained with the new loss to match or surpass a 152-layer network trained with softmax. Even on ILSVRC 2012 the method yields modest but reliable improvements. The magnitude of improvement grows with the degree of imbalance, and the optimal β is larger for coarse-grained datasets than for fine-grained ones, confirming that the framework automatically adapts the strength of re-weighting to the underlying data redundancy.
These results indicate that a theoretically grounded adjustment of per-class loss weights can substantially mitigate the bias toward dominant classes without the overfitting or information loss associated with resampling. The approach therefore offers a practical route to higher accuracy on the skewed distributions typical of real-world imagery, at negligible extra computational cost.
The principal remaining uncertainties are the need to select β via cross-validation and the assumption that a single dataset-level N suffices for all classes. Future work could incorporate class-specific estimates of unique prototypes or learned adaptive weighting to reduce this tuning burden. In the meantime, practitioners facing long-tailed recognition tasks can obtain immediate gains by replacing a standard loss with its class-balanced counterpart and validating β on a modest held-out set.
No sufficiently relevant recommendations were found.
- Paper: Supervised Contrastive Learning, Prannay Khosla et al. (2020). This work extends the exploration of loss design for classification by introducing a supervised contrastive loss that structures representation geometry directly from class labels.
