Hierarchical loss for classification

Cinna Wu, Mark Tygert, Yann LeCunarXiv 2017

Introduction

Standard classification metrics often fail to capture the semantic nuances of errors. In traditional machine learning, cross-entropy loss treats all misclassifications equally—a "poodle" mistaken for a "sheepdog" is penalized as heavily as a "poodle" mistaken for a "skyscraper." This paper introduces a hierarchical "win" metric based on ultrametric trees to reward "near misses," providing a more semantically aware evaluation framework.

The Hierarchical Win Metric

The core of the proposed approach is the Hierarchical Win (and its inverse, the Hierarchical Loss). This metric leverages a-priori hierarchical information to measure success more accurately.

The Ultrametric Tree

All classes are organized into a tree where all leaf nodes (the final target classes) are at an equal distance from the root. This structure represents the taxonomic or semantic relationships between categories.

A taxonomic hierarchy of fish species used to define class relationships.

Calculating the "Win"

To determine the score for a specific input, the model examines the path from the root to the correct leaf node. The "win" is calculated by summing the probabilities assigned by the model to each node along this path, with each level weighted by its depth (e.g., $1/2$ for the root, $1/4$ for the next level, etc.). To ensure a perfect classification results in a win of 1.0, the probability at the final leaf is double-counted.

The weighting scheme for the Hierarchical Win metric. Probabilities are accumulated along the path, with the leaf node double-counted to reach a total win of 1.0.

Experimental Evaluation

The researchers evaluated this approach across several text classification datasets, including:

  • RCV1-v2: Reuters news articles with 364 industry classes.
  • DBpedia Fish: A complex taxonomic hierarchy of 1,298 fish species.
  • LSHTC1: A large-scale subtree from the DMOZ directory.
  • Few-Shot Variants: Subsampled versions of RCV1-v2 to test performance with limited data.

Key Insights

Metric vs. Objective

A significant finding is the decoupling of evaluation and optimization. While the hierarchical loss is a meaningful evaluation tool for humans, using it as a direct optimization objective for Stochastic Gradient Descent (SGD) often leads to local optima. Surprisingly, standard cross-entropy training often reduces hierarchical loss almost as effectively as the hierarchical loss itself.

The Importance of the Logarithm

In deep hierarchies, such as the Fish dataset, training on the "raw" win was ineffective. Applying a logarithm to the win was essential to provide a sufficient gradient signal for deep neural network training.

Utility in Few-Shot Learning

The hierarchical approach showed the most promise in data-scarce scenarios. In one-shot learning on RCV1-v2, the hierarchical loss yielded better accuracy across nearly all metrics, as the hierarchy provides a "roadmap" for relationships not fully captured in the training samples.

Conclusion and Future Work

While hierarchical loss improves "coarse accuracy" (getting the high-level category right), it can struggle with "fine accuracy" in complex datasets. The authors suggest that plain SGD may be too blunt for this loss function. Future work includes developing specialized hierarchical optimization processes and exploring regularization terms that tie the parameters of related classes together more effectively.

Summary updated

BibTeX
@misc{wu2017hierarchical,
  author = {Cinna Wu and Mark Tygert and Yann LeCun},
  title = {{Hierarchical loss for classification}},
  year = {2017},
  eprint = {1709.01062},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1709.01062},
}
Figure