Balanced Meta-Softmax for Long-Tailed Visual Recognition

Jiawei Ren, Cunjun Yu, Shunan Sheng, Xiao Ma, Haiyu Zhao, Shuai Yi, Hongsheng Li

Introduction

Deep classifiers have achieved remarkable success in visual recognition tasks. However, real-world data is rarely distributed evenly; it typically follows a long-tailed distribution. A few "head" classes contain thousands of samples (e.g., person, car), while many "tail" classes have only a handful (e.g., bait, unicycle).

This paper introduces Balanced Meta-Softmax (BALMS), a framework designed to tackle long-tailed data by mathematically correcting the inherent bias in the standard Softmax function. By combining an unbiased "Balanced Softmax" loss with a meta-learning-based "Meta Sampler," the authors achieve state-of-the-art performance across major long-tailed classification and instance segmentation benchmarks.

The Problem: Softmax is Intrinsically Biased

Standard deep learning models, which typically rely on the Softmax function and Cross-Entropy loss, struggle with long-tailed datasets. They tend to over-fit the head classes and ignore the tail.

The authors highlight a fundamental flaw: Softmax is intrinsically biased when the training distribution does not match the test distribution (which is usually expected to be balanced). This mismatch leads to biased gradient estimations during training. Consequently, the model learns to "prefer" head classes simply because they appear more frequently, rather than because their features are more representative.

The Solution: BALMS

The authors propose a two-part solution to address this distribution shift:

1. Balanced Softmax

Using a Bayesian approach, the authors derive a version of Softmax that explicitly accounts for the label distribution shift. By incorporating the training class counts ($n_j$) directly into the loss function, they effectively "cancel out" the prior probability bias of the training set.

  • The Math: Instead of the standard Softmax formula $\frac{e^{\eta_j}}{\sum e^{\eta_i}}$, Balanced Softmax uses $\frac{n_j e^{\eta_j}}{\sum n_i e^{\eta_i}}$.
  • Theoretical Link: The authors prove that optimizing this modified loss is equivalent to minimizing the multi-class generalization error bound. This provides a solid theoretical foundation for a problem that was previously often handled by empirical "tweaks."

2. Meta Sampler

While Balanced Softmax corrects the loss function, the optimization process itself remains challenging when some classes are extremely rare. Simple re-sampling (showing the model more tail images) can lead to "over-balancing," where the model begins to ignore the variations in head classes.

The Meta Sampler uses meta-learning (a bi-level optimization strategy) to learn the optimal sampling rate for each class. It utilizes a small, balanced "meta-set" to guide the training, ensuring the model learns a distribution that maximizes performance on a balanced test set without falling into the over-balancing trap.

Key Insights

  • Softmax is a Prior-Dependent Estimator: The standard Softmax function implicitly assumes the training and test distributions are identical. In long-tailed scenarios, this assumption fails, making the resulting model a biased estimator.
  • The "Over-balance" Trap: Naively combining a balanced loss with balanced sampling (CBS) actually degrades performance. The two methods "double-correct" for the same bias, introducing a new bias toward the tail classes.
  • Unified Theory: The Bayesian derivation for label shift and the derivation for the generalization error bound lead to the exact same functional form, suggesting that Balanced Softmax is a mathematically "natural" solution for imbalanced learning.

Key Results and Fairness

The authors evaluated BALMS on several standard long-tailed benchmarks, including CIFAR-10/100-LT, ImageNet-LT, Places-LT, and LVIS (which features an extreme imbalance factor of over 26,000). BALMS consistently outperformed previous state-of-the-art methods:

  • LVIS Segmentation: BALMS achieved a mask AP of 27.0, significantly higher than standard Softmax (23.7). Most impressively, it boosted the Average Precision for rare classes ($AP_r$) from 13.6 to 19.6, a massive jump for the most difficult categories.
  • CIFAR-10-LT: With an imbalance factor of 200, BALMS reached 81.5% accuracy, outperforming the previous best method by 3.4%.

Visualizing Fairness

A key advantage of BALMS is that it produces a much more uniform "marginal likelihood" across classes. Unlike standard Softmax, which has a high probability of predicting head classes regardless of the input, BALMS treats all classes with equal "respect" at test time.

Marginal likelihood across classes for different imbalance factors.

Limitations and Future Work

  • Computational Overhead: The Meta Sampler relies on bi-level optimization, which is computationally expensive and slower to train than standard methods, particularly on large datasets.
  • Meta-set Requirement: The method requires a balanced meta-set for the inner loop of optimization. While sampling from the training set generally works, finding a balanced set in extremely sparse scenarios might be difficult.
  • Future Directions: The authors suggest extending this framework to other domains, such as machine translation, and exploring more computationally efficient ways to achieve the benefits of meta-learning.

Summary updated

BibTeX
@inproceedings{ren2020balanced,
  author = {Jiawei Ren and Cunjun Yu and Shunan Sheng and Xiao Ma and Haiyu Zhao and Shuai Yi and Hongsheng Li},
  title = {{Balanced Meta-Softmax for Long-Tailed Visual Recognition}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=wyL7SSCnM6y},
}
Figure