Context. When a few classes dominate the training data, plain cross-entropy favors them, and the usual target becomes the balanced error, the average of the per-class error rates. Recent deep-net fixes either divide each class's logit by its weight norm after training or change the loss with per-class margins or weights; they work on benchmarks, but the margin and normalization fixes were not derived from the target's Bayes rule, which this paper writes down. The balanced error is the ordinary error under a uniform class prior, so its Bayes rule is : subtract the log prior from the logits, after training a standard model or inside the softmax during training. A correction that is multiplicative, or that looks at only one of the two labels being compared, is not consistent in general. This is Saerens-style prior correction toward a uniform prior, and in the binary case Elkan's threshold set at the base rate.
Setting. Labels with priors , a scorer , , and . Post-hoc logit adjustment predicts for a standard model. The logit-adjusted loss trains with and predicts . It sits inside the pairwise margin family , which also contains the balanced loss (), the adaptive margin loss of Cao et al. (LDAM, ) and the equalization loss of Tan et al. ().
Theorem (consistency). For any , the pairwise margin loss with and is Fisher consistent for the balanced error; is the logit-adjusted loss with , and the balanced loss. Lemma (binary, if and only if). With temperature , and are consistent for the balanced error exactly when Neither LDAM nor the equalization loss meets the condition, and post-hoc weight normalization is not consistent either.
The Bayes rule for the balanced error ignores the prior. Averaging the per-class errors with equal weights is the ordinary error under , whose Bayes classifier is when . This decision does not move when the priors change with fixed, which makes the balanced error the natural target under label shift. Two procedures follow: shift the logits of an ordinary model afterwards, or train a model whose logits already estimate . In the binary case the rule predicts positive when , Elkan's threshold with a false negative costing times a false positive (my remark; the paper leaves general costs to future work), and shifting the log-odds by handles any cost ratio.
Post-hoc adjustment is additive, which is why it beats weight normalization. With , subtracting is the Bayes rule applied to the model's own probability estimates, and since , any other is the same rule after temperature scaling, the paper's reason for tuning on a miscalibrated net. Weight normalization predicts , a multiplicative rule: when a rare class has a negative logit while some other class is positive, shrinking only pushes it further down, so the rare class can never win. The common choice also assumes the classifier norms track the priors, which on long-tailed CIFAR holds under SGD with momentum and fails under Adam at comparable balanced error, so the method rests on an accident of the optimizer's implicit bias.
The logit-adjusted loss learns the balanced posterior, by two changes of variable. A margin is the same as adding to logit inside the softmax, so the population minimizer satisfies . A class weight turns the risk into unweighted cross-entropy on a distribution with posterior . Together, whose argmax is the Bayes rule of Step 1. Only the ratio matters, so a change in a weight can be offset one for one by a change in the margin, and a margin that depends on the positive label alone (LDAM) or on the negative alone (equalization) cannot produce the factor . The loss is post-hoc adjustment of the scorer , so the two routes coincide for convex models and differ for nets only through the local minimum reached, and applying both at once double-counts the prior.
In the binary case, consistency is one equation at . The binary pairwise loss is proper composite, so its Bayes score is for an invertible link , and consistency means . The ratio of the two loss derivatives fixes the link (Reid and Williamson), and at it gives the lemma's condition. Pure weighting satisfies it at every . A pure antisymmetric margin needs , so it must shrink with the temperature, and in the hinge limit fixed positive margins drop out and only the weights decide, the cost-sensitive SVM result. Weights and margins each sized for the full correction correct twice: in a check of mine at and , the Bayes score at is for either single correction, for both and for plain logistic loss.
In experiments only the consistent methods find the Bayes separator, and on long-tailed benchmarks the gains are a few points. On two Gaussians with 5% positives and an affine classifier, the logit-adjusted loss lands close to the balanced-error Bayes separator, while plain ERM, LDAM and the equalization loss end up away from it; post-hoc adjustment reaches the Bayes error near , and weight normalization at any makes things worse. On CIFAR-10-LT, CIFAR-100-LT, ImageNet-LT and iNaturalist, balanced error is 27.16, 61.64, 53.11 and 38.66 for ERM, 22.60, 58.24, 49.66 and 33.98 for post-hoc adjustment at and 22.33, 56.11, 48.89 and 33.64 for the logit-adjusted loss, with the gain in the rare classes. The method is not uniformly best (weight normalization at slightly beats both untuned variants on one CIFAR-100 profile, though post-hoc adjustment with overtakes it), and adding the inconsistent LDAM margin on top gives the best iNaturalist number, so consistency does not settle the ranking at finite samples.
Consequences and limits. Imbalance is a decision-rule problem. Reweighting is consistent in the population but does little once a flexible model separates the training data (Byrd and Lipton). For a binary fraud score, post-hoc adjustment is the cost threshold written in log-odds, so the threshold should come from the actual costs , with the base rate as one special case. A model trained with the adjusted loss outputs the balanced log-odds , the log likelihood ratio, so a downstream rule that reads the score as a probability must add a prior's logit back: the training prior gives training-distribution probabilities and the population prior gives population probabilities directly, even when negatives were subsampled for training (my remark). Post-hoc adjustment also presumes calibrated estimates of , so Platt, isotonic or temperature scaling comes first. Fisher consistency is a population statement about the minimizer: Kini et al. (2021) show, for overparameterized linear classifiers trained past zero training error, that additive logit offsets help early in training but lose their effect at convergence, while multiplicative logit scalings shape the max-margin solution, the regime Soudry et al. describe. The paper takes the priors as known training frequencies and targets the balanced error only, and its gains are a few points on vision data with one optimizer.
Terms
- Balanced error
- : ordinary error under a uniform class prior.
- Balanced posterior
- ; its argmax is the Bayes rule for the balanced error.
- Post-hoc logit adjustment
- Predict ; is the plug-in Bayes rule, other act as a temperature.
- Logit-adjusted loss
- Softmax cross-entropy on ; at the optimum .
- Pairwise margin loss
- : weights and margins together.
- Consistency condition
- , for any ; only matters.
- Weight normalization
- Predict ; multiplicative, so not consistent, and depends on the optimizer.
- Binary rule
- Predict positive iff : Elkan's with .
- Binary lemma
- Consistent iff , standard sigmoid.
- Recovering probabilities
- An adjusted-loss model's score is the log likelihood ratio; adding of a prior gives the log-odds of under that prior.
Quiz
- Why is it a mistake to apply post-hoc logit adjustment to a model trained with the logit-adjusted loss?The trained logits estimate already; subtracting again targets . In the binary check the double correction overshoots by as much as no correction falls short.
- Why does class reweighting by help little when a deep net fits the training data perfectly?Weighting scales each example's loss, and a solution with zero training loss has zero loss under every weighting. Reweighting is consistent in the population, but it gives no pressure to move a separator that already separates.
- Why does the optimizer matter for weight normalization with ?The method assumes rare classes get smaller classifier norms. That holds under SGD with momentum but the norms are flat or reversed under Adam at similar balanced error, so the correction depends on the optimizer's implicit bias.
- Why can post-hoc logit adjustment benefit from on a deep net?Since , tuning is applying the exact rule to temperature-scaled probabilities. The rule presumes calibrated estimates, which modern nets lack.
Sources
- Aditya Krishna Menon, Sadeep Jayasumana, Ankit Singh Rawat, Himanshu Jain, Andreas Veit, and Sanjiv Kumar. Long-tail learning via logit adjustment. ICLR, 2021.
- Ganesh Ramachandra Kini, Orestis Paraskevas, Samet Oymak, and Christos Thrampoulidis. Label-Imbalanced and Group-Sensitive Classification under Overparameterization. NeurIPS, 2021.
- Kaidi Cao, Colin Wei, Adrien Gaidon, Nikos Arechiga, and Tengyu Ma. Learning Imbalanced Datasets with Label-Distribution-Aware Margin Loss. NeurIPS, 2019.
- Jingru Tan et al. Equalization Loss for Long-Tailed Object Recognition. CVPR, 2020.