The Tree Loss: Improving Generalization with Many Classes

Yujie Wang, Mike IzbickiAISTATS 2022

Abstract

In multi-class classification, standard cross-entropy loss treats every category as an independent entity, ignoring inherent semantic relationships. This paper introduces the Tree Loss, a drop-in re-parameterization strategy that organizes classes into a hierarchical tree structure. By forcing semantically similar classes to share parameters, the Tree Loss achieves the first provable improvement in generalization error over cross-entropy in "many-class" scenarios. Our experiments on ImageNet, CIFAR100, and large-scale text datasets show that Tree Loss consistently improves accuracy and ensures that model errors are more semantically grounded.

Introduction: The Independence Problem in Classification

Standard multi-class classification models typically learn independent weight vectors for every class. For instance, in a 1,000-class dataset, a model treats a "Husky" and a "Toaster" with the same level of distinction as it treats a "Husky" and a "Beagle." This lack of structural awareness forces models to require vast amounts of data to learn nuances that are already captured by the semantic relationships between labels. When data is sparse or the number of classes is high, models often make "silly" mistakes, confusing animals with inanimate objects.

Methods: Hierarchical Parameter Sharing

The Tree Loss addresses this by re-parameterizing the final weight matrix $W$ based on a tree structure. This process involves three main steps:

  1. Tree Construction: Classes are organized into a tree, either manually or automatically using algorithms like the Cover Tree, which utilizes distance metrics between labels (e.g., word embeddings).
  2. Parameter Sharing (U-Tree & V-Tree):
    • U-Tree: A class's weight vector is defined as the sum of vectors along the path from the root to its leaf.
  3. V-Tree: This variant introduces "pseudoclasses" at internal nodes (e.g., a "Dog" node), allowing shared parameters to provide training signals to all descendant classes.
  4. Optimization: Since this is a re-parameterization, it is compatible with standard Stochastic Gradient Descent (SGD). Updating a specific leaf class automatically updates its shared ancestral parameters.
Comparison of U-Tree and V-Tree hierarchical structures for parameter sharing.

Key Insights and Theoretical Bounds

The Tree Loss is the first multi-class loss function with a provably better convergence rate than cross-entropy. Theoretically, it shifts the error bound from $O(\sqrt{k/n})$ toward $O(\sqrt{\log k/n})$ under ideal conditions. This improvement is rooted in the Frobenius Norm Connection: by forcing parameter overlap, the Tree Loss reduces the overall norm of the weight matrix, which is directly tied to generalization error.

Furthermore, the method is remarkably robust. Even with noisy or suboptimal tree structures, the Tree Loss maintains a performance floor comparable to cross-entropy while offering a significantly higher ceiling for accuracy.

Experimental Results

The authors validated the Tree Loss across diverse benchmarks, including CIFAR100, ImageNet, and a massive Twitter emoji prediction dataset.

Accuracy vs. Number of Classes (k) comparing Tree Loss against Cross Entropy, SimLoss, and HSM.
  • ImageNet: Top-1 Accuracy improved to 76.52% (from 75.30% with cross-entropy).
  • CIFAR100: Top-1 Accuracy increased from 51.87% to 52.78%.
  • Twitter (Emoji Prediction): Accuracy rose from 19.95% to 20.96%.

Beyond raw accuracy, the Tree Loss significantly improved Similarity Accuracy (SA). This metric reveals that when the model fails, its "mistakes" are semantically closer to the ground truth (e.g., misclassifying a Husky as a Beagle rather than a Bus).

Limitations and Future Outlook

The primary trade-off for these gains is computational speed. The requirement to sum parameters along a path during the forward pass resulted in an approximately 2x slowdown in training during experiments. Future work may involve combining the Tree Loss with extreme-scale techniques like negative sampling to handle millions or billions of classes. Additionally, while the method is resilient to noise, its peak performance remains dependent on the quality of the initial similarity metric used to build the tree.

Summary updated

BibTeX
@inproceedings{wang2022tree,
  author = {Yujie Wang and Mike Izbicki},
  title = {{The Tree Loss: Improving Generalization with Many Classes}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2022},
}
Figure