Papers
Topics
Authors
Recent
Search
2000 character limit reached

Adaptive Class-Balanced Loss

Updated 5 July 2026
  • Adaptive Class-Balanced Loss is a training objective that dynamically adjusts class weights using signals like effective sample counts and validation difficulty.
  • It integrates various adaptive mechanisms—frequency-based, difficulty-based, and time-based—to address long-tailed data distributions and enhance minority class performance.
  • Its plug-and-play design allows it to replace standard losses in diverse systems, from object detection and segmentation to continual learning and document classification.

Adaptive class-balanced loss denotes a family of re-weighted training objectives for imbalanced learning in which the contribution of each class is not treated as fixed under ordinary empirical frequency, but is adjusted by a class-aware signal such as effective sample count, validation-set difficulty, global foreground/background loss statistics, ordered class-wise error, or task age in continual learning. The common starting point is the class-balanced re-weighting scheme based on the “effective number of samples,” introduced to model diminishing returns from additional examples of head classes, and subsequently instantiated in object detection, document classification, segmentation, tabular boosting, and continual learning (Cui et al., 2019).

1. Conceptual scope

Class-balanced loss emerged as a response to the long-tailed regime in which “a few classes account for most of the data, while most classes are under-represented.” In its canonical form, it modifies a standard classification loss by assigning larger weight to classes with smaller effective support, rather than leaving all examples to contribute equally under plain cross-entropy (Cui et al., 2019).

The adjective adaptive has several meanings in the literature. In some works, adaptation is still dataset-level: class weights are computed from class counts once and then reused throughout training, as in the effective-number loss used in long-tailed image classification and in AraDIC for Arabic document classification (Cui et al., 2019, Daif et al., 2020). In other works, the weights evolve with training: Class-wise Difficulty-Balanced loss recomputes per-class difficulty from validation accuracy after each epoch; CBMT recalibrates foreground/background terms from global mean pseudo-label losses; OWAdapt reorders class-wise errors at each optimization step; AutoBalance updates class weights, logit shifts, and temperatures by bilevel optimization on a validation objective; and the method explicitly named Adaptive Class-Balanced loss in exemplar-free class-incremental learning uses time-based class weighting over tasks (Sinha et al., 2020, Tang et al., 2023, Maldonado et al., 2023, Li et al., 2022, Xu et al., 4 Jun 2026).

This suggests two broad interpretations. One is a narrow interpretation in which “adaptive” means that the weighting function changes during optimization or across tasks. The other is a broader interpretation in which the loss is class-balanced by a signal more informative than raw empirical frequency alone.

2. Mathematical foundation

The baseline object is the ordinary cross-entropy. For a single-label problem with predicted probabilities p\mathbf p and one-hot target y\mathbf y, the class-balanced cross-entropy replaces the uniform per-example contribution with a class-dependent weight:

LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.

The key question is how wiw_i is defined (Cui et al., 2019).

In the effective-number framework, class ii with nin_i training samples is assigned effective number

Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},

and weight

wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},

optionally normalized. The parameter β[0,1)\beta\in[0,1) controls the smoothness of re-weighting, and the original formulation recommends cross-validating β[0.9,0.9999]\beta\in[0.9,0.9999] (Cui et al., 2019). The same re-weighting can be attached not only to softmax cross-entropy, but also to sigmoid-style losses and focal loss, producing class-balanced CE, class-balanced sigmoid CE, and class-balanced focal variants (Cui et al., 2019).

AraDIC adopts this form directly for document classification. For an example with logits y\mathbf y0 and class label y\mathbf y1, the loss is

y\mathbf y2

with

y\mathbf y3

and the paper fixes y\mathbf y4 (Daif et al., 2020). That implementation is explicitly a plain cross-entropy re-weighted by y\mathbf y5 and “does not add an explicit focal-loss y\mathbf y6 component” (Daif et al., 2020).

The effective-number formulation is important because it sits between two extremes. It preserves the simplicity of class-weighted CE, but replaces direct inverse-frequency heuristics with a quantity motivated by overlap and diminishing information gain as more samples from a class are observed (Cui et al., 2019).

3. Principal adaptive mechanisms

A first mechanism is frequency-based adaptation. Here the loss is adapted to the class histogram of the training set through effective-number weights. This is the defining construction in the original class-balanced loss, and it is the form reused in AraDIC and in the “ENet” object-detection experiments on BDD100K (Cui et al., 2019, Daif et al., 2020, Phan et al., 2020).

A second mechanism is difficulty-based adaptation. Class-wise Difficulty-Balanced loss argues that “the number of available training data may not be always a good clue to determine the weighting strategy” because some minority classes can already be sufficiently represented. It therefore defines per-class difficulty at epoch y\mathbf y7 by

y\mathbf y8

and sets

y\mathbf y9

An optional dynamic focusing exponent is also defined through the current bias

LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.0

with LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.1 (Sinha et al., 2020). This makes the weight depend on how the model is currently serving each class rather than on counts alone.

A third mechanism is global loss calibration under pseudo-label imbalance. In CBMT for source-free domain adaptive fundus segmentation, the calibrated BCE replaces the background term by a factor LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.2, where LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.3 and LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.4 are global mean losses for pixels whose pseudo-label is foreground or background. The pseudo-label threshold is LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.5, and an LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.6 confidence filter keeps only “informative” pixels when collecting statistics (Tang et al., 2023). This is adaptive because the weighting factor is estimated from the evolving target-domain pseudo-label distribution.

A fourth mechanism is time-based class balancing. The exemplar-free continual-learning method explicitly named Adaptive Class-Balanced loss introduces a virtual sample count

LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.7

for class LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.8 first seen at task LCB-CE(p,y)=i=1Cwiyilogpi.\mathcal L_{\rm CB\text{-}CE}(\mathbf p,\mathbf y) = -\,\sum_{i=1}^C w_i\,y_i\log p_i.9, and then defines

wiw_i0

The corresponding weighted cross-entropy is

wiw_i1

In the reported experiments, wiw_i2, wiw_i3, wiw_i4, and wiw_i5 (Xu et al., 4 Jun 2026). The design intention is explicit: older prototype-based classes are strongly up-weighted when they are most under-represented and then gradually annealed.

A fifth mechanism is ordered error aggregation. OWAdapt first computes class-wise cross-entropy errors

wiw_i6

sorts them into wiw_i7, and applies an Ordered Weighted Averaging operator

wiw_i8

The weight vector is generated from a quantifier wiw_i9 by

ii0

Because the weights are attached to the ranking of class errors rather than to fixed class identities, the worst-served classes at a given step receive the largest coefficients (Maldonado et al., 2023).

A sixth mechanism is bilevel adaptation by validation objectives. AutoBalance introduces a parametric cross-entropy with multiplicative class weights ii1, additive logit shifts ii2, and per-class temperatures or margins ii3:

ii4

The model parameters are trained on a lower-level training problem, while ii5 are updated on a validation objective by approximate implicit differentiation (Li et al., 2022). In this formulation, class balancing is not hand-specified once for all; it is optimized against the desired downstream criterion.

4. Integration into learning systems

One of the practical attractions of class-balanced loss is that many instantiations require only local changes to the criterion, not to the backbone architecture. In the BDD100K object-detection study, Phan and Yamamoto keep feature extraction, localization-regression heads, hard-negative mining, and data augmentation unchanged, and “the only change needed is to replace the standard classification-head loss ii6 by one of the above weighted variants” in an SSD-style detector with VGG16 backbone and extra up-sampling layers for small objects (Phan et al., 2020).

AraDIC likewise uses class-balanced loss as a drop-in objective within an end-to-end pipeline. Raw Arabic text is rendered as ii7 grayscale character images, passed through a character encoder CNN to obtain 128-dimensional embeddings, and then classified by either a 1D-CNN or a 3-layer BiGRU. The class-balanced softmax cross-entropy is applied at the classifier output, and both encoder and classifier are updated jointly with Adam at learning rate ii8 and batch size ii9 (Daif et al., 2020).

The GBDT study shows that class-balanced objectives are not restricted to neural networks. For binary tasks, the paper writes the general re-weighted cross-entropy

nin_i0

and then derives gradients and Hessians for Weighted Cross-Entropy, Focal Loss, Asymmetric Loss, Asymmetric Cross-Entropy, and Asymmetric Weighted Cross-Entropy so that LightGBM, XGBoost, and SketchBoost can optimize the corresponding second-order Taylor surrogate (Luo et al., 2024). Notably, the same paper states that its use of the word “adaptive” refers to per-dataset hyperparameter tuning with Optuna rather than to a dynamically changing schedule during training (Luo et al., 2024).

The theoretical literature has also shifted from heuristic weighting to surrogate design. “Improved Balanced Classification with Theoretically Grounded Loss Functions” introduces Generalized Logit-Adjusted and Generalized Class-Aware losses for the balanced objective. GLA losses are Bayes-consistent but their nin_i1-consistency bounds scale at least as nin_i2, whereas GCA losses are nin_i3-consistent for any bounded or complete hypothesis set and scale as nin_i4 in the common nin_i5 case (Cortes et al., 30 Dec 2025). This places class-aware weighting and class-aware margin calibration within a common consistency framework.

5. Empirical record across application domains

The empirical evidence is heterogeneous because different papers optimize different metrics, but several regularities recur. In specialized object detection on BDD100K, evaluation is by per-class recall at fixed nin_i6 and nin_i7 rather than by overall mAP. Under that criterion, the effective-number class-balanced loss (“ENet”) improves Bike recall from nin_i8 to nin_i9, Bus from Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},0 to Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},1, and Motor from Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},2 to Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},3, while Balanced Cross-Entropy with fixed Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},4 attains the highest average recall at Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},5 versus Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},6 for the original CE (Phan et al., 2020).

In Arabic document classification, class-balanced loss produces systematic macro-F1 gains. On the Arabic Wikipedia Title dataset, BiGRU without CB loss reports micro/macro F1 of Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},7, while BiGRU with CB loss reports Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},8. On the Arabic Poetry dataset, the corresponding numbers are Eni=1βni1β,E_{n_i}=\frac{1-\beta^{n_i}}{1-\beta},9 without CB and wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},0 with CB (Daif et al., 2020). The pattern in the paper is that class-balanced weighting improves minority-class behavior while maintaining or slightly improving micro-F1.

In long-tailed image and video recognition, difficulty-adaptive weighting also improves balanced behavior. On ImageNet-LT with ResNet-10, Class-wise Difficulty-Balanced CE alone reports Top-1 accuracy of wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},1, compared with wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},2 for focal loss and wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},3 for EQL. On the EGTEA-Gaze+ video verb benchmark, CDB-CE improves test Acc@Top1 from wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},4 under unweighted CE to wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},5, and macro-Recall from wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},6 to wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},7 (Sinha et al., 2020).

In source-free fundus segmentation, the calibration component itself yields a measurable improvement. On RIM-ONE-r3, the ablation study reports Dice wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},8 for “+EMA only,” wi=1β1βni,w_i=\frac{1-\beta}{1-\beta^{n_i}},9 for “+EMA+Calib only,” and β[0,1)\beta\in[0,1)0 for the full CBMT with EMA, augmentation, and calibration; ASSD decreases from β[0,1)\beta\in[0,1)1 to β[0,1)\beta\in[0,1)2 and then to β[0,1)\beta\in[0,1)3 (Tang et al., 2023). The paper further notes that without calibration the predicted cup-pixel ratio collapses toward zero, whereas calibration keeps it near the oracle ratio (Tang et al., 2023).

In exemplar-free continual learning, the time-adaptive ACB schedule improves prototype rehearsal. On TinyImageNet with β[0,1)\beta\in[0,1)4 tasks, baseline rehearsal reports β[0,1)\beta\in[0,1)5 and β[0,1)\beta\in[0,1)6, while “+ACB” gives β[0,1)\beta\in[0,1)7 and β[0,1)\beta\in[0,1)8, and the full CEOS+ACB model gives β[0,1)\beta\in[0,1)9 and β[0.9,0.9999]\beta\in[0.9,0.9999]0 (Xu et al., 4 Jun 2026). The same study reports consistent β[0.9,0.9999]\beta\in[0.9,0.9999]1 to β[0.9,0.9999]\beta\in[0.9,0.9999]2 percentage-point gains from replacing unweighted cross-entropy with β[0.9,0.9999]\beta\in[0.9,0.9999]3 across CIFAR-100, TinyImageNet, ImageNet-100, and CUB-200 (Xu et al., 4 Jun 2026).

OWAdapt reports a broader cross-dataset comparison on 13 image-classification datasets and three architectures. Averaged over all datasets and architectures, OWAdapt obtains Accuracy β[0.9,0.9999]\beta\in[0.9,0.9999]4, F1 macro β[0.9,0.9999]\beta\in[0.9,0.9999]5, minimum class recall β[0.9,0.9999]\beta\in[0.9,0.9999]6, and minimum class F1 β[0.9,0.9999]\beta\in[0.9,0.9999]7, compared with β[0.9,0.9999]\beta\in[0.9,0.9999]8, β[0.9,0.9999]\beta\in[0.9,0.9999]9, y\mathbf y00, and y\mathbf y01 for standard CE (Maldonado et al., 2023). This is evidence that per-step ranking of class-wise errors can function as an adaptive balancing mechanism even without explicit class-frequency formulas.

6. Limitations, misconceptions, and open directions

A common misconception is that any loss that helps under imbalance is therefore class-balanced in the same sense. The BDD100K study makes a sharper distinction: focal loss “helps background vs. foreground imbalance more than foreground–foreground class imbalance,” because it adapts to easy versus hard predictions but “does not encode long-term class frequencies” (Phan et al., 2020). This is why focal loss can improve overall detection behavior without matching the minority-class gains of explicit class-balancing.

Another misconception is that raw inverse-frequency weighting is always the natural solution. The same object-detection study states that static inverse-frequency weights can be extreme for very rare classes and may cause instability when a batch has zero or few samples of that class (Phan et al., 2020). Difficulty-based and ordered-error methods were motivated in part by this objection: they attempt to weight classes by current training need rather than by count alone (Sinha et al., 2020, Maldonado et al., 2023).

Adaptive class balancing also does not solve all causes of poor minority performance. On BDD100K, the method “does not fix data-annotation issues” such as ambiguous “Car” versus “Truck” boxes or overlapping “Motor”/“Person” annotations, and it leaves other imbalance axes—“object size, lighting domains, occlusion”—unaddressed (Phan et al., 2020). This suggests that class-aware weighting is orthogonal to label cleaning, soft targets, and other distribution-shift remedies.

The word adaptive itself is not uniform across papers. CALF, for example, is conditionally adaptive because it chooses one of seven elemental segmentation losses from dataset skewness and kurtosis, but “once the appropriate elemental loss is selected, it remains fixed for the entire run” (Alam et al., 6 Apr 2025). The GBDT study similarly states that no time-dependent schedule was used; “adaptive” there means tuning the loss hyperparameters per dataset by 5-fold CV and early stopping (Luo et al., 2024). By contrast, CDB, CBMT, OWAdapt, AutoBalance, and the continual-learning ACB all change their effective weighting signal during optimization or across tasks (Sinha et al., 2020, Tang et al., 2023, Maldonado et al., 2023, Li et al., 2022, Xu et al., 4 Jun 2026).

Open directions are already visible in the surveyed literature. Proposed extensions include defining an “effective number” per size-bin or per domain, using multi-stage training with different losses at different phases, smoothing noisy difficulty estimates, extending difficulty-based weighting to multi-label settings, and moving from heuristic class weights to theoretically grounded class-aware surrogate families with stronger consistency guarantees (Phan et al., 2020, Sinha et al., 2020, Cortes et al., 30 Dec 2025). The field therefore spans both pragmatic engineering—often implemented by replacing only the classification term—and a more formal program of balanced-risk surrogate design.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Adaptive Class-Balanced Loss.