In the world of machine learning, we often assume our data is neatly balanced. In reality, data is messy and "long-tailed": a few categories (the "head") have thousands of examples, while the vast majority (the "tail") have only a handful. Standard models tend to ignore the tail to please the head. This paper presents a mathematically elegant and practically simple fix known as logit adjustment.
The Challenge of Long-Tailed Data
Most machine learning models are trained using Empirical Risk Minimization (ERM), which aims to maximize overall accuracy. On a balanced dataset, this is fine. But on a long-tailed dataset—like a species classification task where there are millions of pigeons but only ten rare owls—a model can achieve 99.9% accuracy just by predicting "pigeon" every single time.
To fix this, researchers often use balanced error, which averages the error rate of each class regardless of how many samples it has. Previous attempts to solve this involved over-sampling rare classes (which leads to overfitting) or "weight normalization" (which tries to re-scale the model's internal weights). However, these methods are often heuristics that lack a solid theoretical foundation or fail when paired with modern optimizers.
The Logit Adjustment Framework
The authors propose a "logit adjustment" framework to handle long-tailed data by shifting a model's output scores (logits) based on class frequencies. In a neural network, the final layer produces "logits"—raw scores for each class—before they are turned into probabilities via the softmax function.
The paper proposes two ways to apply this:
- Post-hoc Logit Adjustment: You take a model already trained on imbalanced data and, at prediction time, subtract a value proportional to the log of the class frequency from the logits: $f_y(x) - \tau \log \pi_y$. This "penalizes" frequent classes and gives rare ones a fighting chance.
- Logit-Adjusted Loss: You bake this adjustment directly into the loss function during training. By adding the log-frequency offset inside the softmax cross-entropy, the model is forced to learn a "large relative margin" between rare positive labels and dominant negative ones.
The key differentiator here is that these methods are Fisher consistent. This means that if you had infinite data and a perfect model, minimizing this loss would lead you exactly to the mathematically optimal solution for minimizing balanced error.
Key Insights: Why Previous Methods Fail
The "Adam" Problem
One of the most interesting findings is why previous "weight normalization" techniques often fail. Those methods assume that a class's importance is reflected in the norm (magnitude) of its weight vector. The authors show that while this is true when using standard Momentum optimizers, it completely breaks down when using Adam.
Under Adam, weight norms don't correlate with class frequency, making weight normalization ineffective. Logit adjustment, being an additive shift, doesn't care which optimizer you use.
Additive vs. Multiplicative
Weight normalization is multiplicative, while logit adjustment is additive. The authors demonstrate that if a rare class has a negative score, no amount of multiplication will ever make it the "top" prediction. Additive shifts, however, can rescue these rare classes regardless of the original score's sign. Furthermore, unlike complex meta-learning or multi-stage training schemes, logit adjustment requires almost no extra code and zero extra training time.
Datasets and Results
The authors evaluated their approach on four major benchmarks: CIFAR-10-LT, CIFAR-100-LT, ImageNet-LT, and iNaturalist 2018.
Logit adjustment consistently outperformed existing state-of-the-art methods across all datasets. On CIFAR-10-LT, it achieved an 8% relative reduction in error compared to standard weight normalization. On the massive iNaturalist dataset, the logit-adjusted loss achieved a balanced error of 33.64%, significantly better than standard ERM (38.66%) and outperforming specialized "adaptive margin" losses.
As shown above, logit adjustment not only yields lower balanced error compared to ERM and adaptive methods, but its decision boundaries closely match the theoretical Bayes optimal. When combined with other techniques like "adaptive margins," it pushed the state-of-the-art even further, reaching 31.56% error on iNaturalist.
Limitations and Future Work
The authors acknowledge a fundamental trade-off: by significantly improving performance on "tail" (rare) classes, you often see a slight dip in performance on "head" (common) classes. While the average (balanced) error improves, the overall accuracy might decrease if the test set is as imbalanced as the training set.
Future work suggested includes exploring how logit adjustment interacts with more complex architectures and integrating it with meta-learning approaches that try to "learn" the best offsets automatically rather than relying purely on label frequencies.
Summary updated