Imbalanced image classification with complement cross entropy

Yechan Kim, Younkwan Lee, Moongu Jeon

TL;DR

This paper introduces Complement Cross Entropy (CCE), a simple yet powerful loss function designed to fix the performance drop-off seen in deep learning models when training on imbalanced datasets. By forcing the model to "neutralize" its predictions for incorrect classes (making them uniform), CCE ensures that minority classes aren't drowned out by majority ones, leading to better feature extraction and faster convergence.

What Problem Does This Paper Address?

In an ideal world, datasets are perfectly balanced. In the real world, they are "long-tailed"—a few majority classes have thousands of samples, while many minority classes have only a handful.

Standard Softmax Cross Entropy (CE) is the industry standard for classification, but it has a blind spot: it focuses almost entirely on maximizing the score of the ground-truth class. It largely ignores the distribution of the "incorrect" classes. In imbalanced scenarios, this leads to a "cumulative error" where the model becomes overconfident in majority classes, and the remaining "noise" in the incorrect class scores can easily overwhelm the signal for rare classes.

Existing fixes like oversampling (duplicating rare images) or undersampling (deleting common ones) often introduce noise or throw away valuable data. The authors sought a way to improve the loss function itself without needing complex data manipulation.

Methods

The authors propose a two-pronged approach to loss:

  1. Complement Entropy ($C(\hat{y})$): Instead of just looking at the correct class, this term calculates the Shannon entropy of all incorrect classes. The goal is to maximize this entropy. In plain English: the model is encouraged to be equally "uncertain" about all the wrong answers. This "neutralizes" the incorrect classes, preventing any one of them from becoming a threat to the correct prediction.
  2. The CCE Loss Function: Previous research (Complement Objective Training) required two separate optimization steps, which doubled training time. This paper simplifies the process into a single loss function: $$Loss = H(y, \hat{y}) + \frac{\gamma}{K-1} C(\hat{y})$$ Where $H$ is standard cross entropy, $C$ is the complement entropy, and $\gamma$ is a modulating factor (the authors found $\gamma = -1$ works best across almost all scenarios).

By combining these, the model learns to push the ground-truth class probability up while simultaneously flattening the "landscape" of the incorrect classes.

Datasets

The researchers evaluated CCE across a wide variety of benchmarks, using both synthetic and real-world imbalance:

  • Synthetically Imbalanced: CIFAR-10, CIFAR-100, Fashion MNIST, and Tiny ImageNet. These were modified into "Long-tailed" (exponential decay) and "Step" (half the classes are rare) distributions.
  • Real-world Imbalance:
    • Road Marking: A dataset of 27 classes of road signs/markings which is naturally imbalanced.
  • SVHN (Street View House Numbers): A classic dataset of house numbers from Google Street View.

Key Insights and Ideas

  • The Power of Neutralization: The "aha moment" is that we don't necessarily need to "boost" minority classes with higher weights. Instead, by "neutralizing" the competition (the incorrect classes), we give the minority class a clearer path to being the "overwhelming" winner in the softmax distribution.
  • Better Feature Separation: Using t-SNE visualizations, the authors showed that CCE produces much tighter, more distinct clusters in the feature space. For example, in Fashion MNIST, classes like 'T-shirt' and 'Shirt'—which are often confused—are pushed much further apart compared to standard training.
  • Efficiency: Because CCE is a single-pass loss function, it is roughly 1.7x faster than previous bi-objective complement training methods while achieving better results.

Key Results

CCE consistently outperformed standard Empirical Risk Minimization (ERM), Focal Loss, and previous Complement Objective Training (COT) across various architectures (ResNet, EfficientNet, DenseNet).

  • Accuracy Boost: On CIFAR-10 with a 100:1 imbalance ratio, CCE achieved 71.98% accuracy compared to ERM’s 68.80%.
  • Road Marking Success: On the ResNet-101 architecture, CCE improved accuracy by a massive 11.02% over standard cross entropy.
  • Faster Convergence: The models didn't just get more accurate; they got there faster. On the Road Marking dataset, the error rate for CCE dropped much more sharply in the early epochs than standard ERM.

Limitations and Future Work

Despite the improvements, the authors identified a specific "Weakness Analysis" area: Visual Similarity. CCE still struggles when classes are visually ambiguous. For example, the model might still misclassify a "dog" as a "bird" if the dog is small and fluffy, or a "horse" as a "deer" if the background (a field) is a dominant feature.

The authors suggest that future work should focus on:

  1. Mitigating visual confusion: Incorporating techniques to specifically handle categories that look alike.
  2. Hybrid Approaches: Combining CCE with other "tricks" like advanced data augmentation or specialized sampling strategies to see if the gains are additive.

Summary updated

BibTeX
@article{kim2021imbalanced,
  author = {Yechan Kim and Younkwan Lee and Moongu Jeon},
  title = {{Imbalanced image classification with complement cross entropy}},
  journal = {Pattern Recognition Letters},
  year = {2021},
  doi = {10.1016/j.patrec.2021.07.017},
}
Figure