Learning Structured Representations by Embedding Class Hierarchy with Fast Optimal Transport

Siqi Zeng, Sixian Du, Makoto Yamada, Han Zhao

In the world of deep learning, we often treat class labels as independent categories. However, the real world is structured: a "Golden Retriever" is a type of "Dog," which is a type of "Animal." Capturing this hierarchy in a model’s feature space can lead to more interpretable representations and better generalization.

A new paper accepted to ICLR 2025, "Learning Structured Representations by Embedding Class Hierarchy with Fast Optimal Transport," introduces a powerful way to bake these hierarchies into neural networks using the mathematics of Optimal Transport.

TL;DR

The authors propose OT-CPCC, a new regularization framework that uses Optimal Transport (Earth Mover’s Distance) to align feature space geometry with label hierarchies. By introducing a novel linear-time algorithm called Fast FlowTree, they achieve state-of-the-art hierarchical representation learning that is both more accurate than previous "mean-based" methods and efficient enough for large-scale datasets.

What Problem Does This Paper Address?

Previous work (specifically $\ell_2$-CPCC) tried to embed hierarchies by calculating the Euclidean distance between the means of different classes in the feature space and forcing those distances to match the "tree distance" in a label hierarchy.

The problem? Class means are often liars.

Comparison of distance calculation using class means versus individual samples.

If a class distribution is multi-modal (meaning it has several distinct clusters in the feature space), the mean might fall in a "no-man's land" where no actual data points exist. This oversimplification ignores the internal variance and shape of class distributions, leading to a loss of hierarchical information. The challenge is to find a way to measure the distance between entire distributions of samples rather than just their averages, without making the training process prohibitively slow.

Methods

The authors bridge this gap using Optimal Transport (OT), specifically the Earth Mover’s Distance (EMD). Think of EMD as the minimum "work" required to transform one pile of dirt (one class distribution) into another.

Key Innovations:

  1. OT-CPCC Framework: Instead of aligning distances between class centroids, the authors use EMD to measure the distance between sets of samples from different classes. They prove that this approach is a mathematical generalization of the previous $\ell_2$ method—specifically, they are equivalent if the class distributions are Gaussians with the same covariance.
  2. Fast FlowTree (FastFT): Exact EMD is computationally expensive ($O(n^3 \log n)$). To make this practical for deep learning, the authors developed FastFT.
An example of the augmented tree used in FastFT, where leaves represent individual samples.

By constructing an "augmented tree" that connects individual data samples to the label hierarchy, they reduce the complex OT problem to a greedy matching process that runs in linear time ($O(nd)$).

  1. Differentiability: Using Danskin’s Theorem, the authors show how to backpropagate through these OT-based distances, even though the underlying matching algorithms are technically non-differentiable.

Datasets

The authors evaluated their method across seven diverse benchmarks:

  • Standard Benchmarks: CIFAR-10 and CIFAR-100.
  • Large-Scale/Fine-Grained: iNaturalist-mini (INAT).
  • BREEDS Benchmarks: Four specialized subsets of ImageNet (LIVING17, NONLIVING26, ENTITY13, ENTITY30) designed to test how models handle "subpopulation shifts" (e.g., training on some types of dogs and testing on others).

Key Insights and Ideas

  • Multi-modality is the Norm: The authors used Gaussian Mixture Models (GMMs) to track class distributions during training. They found that for most datasets, the "best" number of components was much higher than one, confirming that class means are indeed poor representatives of feature distributions.
  • Finer-Grained Gradients: Unlike the $\ell_2$ method, which gives every sample in a class the same "push" toward the mean, EMD-based gradients assign different importance to different pairs of data points. This provides a more informative signal to the neural network during training.
  • Interpretability via CPCC: The Cophenetic Correlation Coefficient (CPCC) measures how well the feature distances correlate with the tree distances. The authors found that their OT-based approach consistently achieved higher "Test CPCC" scores, meaning the learned feature space actually looks like the hierarchy we intended to embed.

Key Results

  • Efficiency: FastFT is significantly faster than exact EMD and even outperforms other approximations like Sinkhorn or Sliced Wasserstein Distance (SWD) in terms of wall-clock time per epoch. On the INAT dataset, FastFT was even faster than the simple $\ell_2$ baseline.
  • Generalization: On the BREEDS benchmarks, OT-CPCC methods (especially FastFT and EMD) consistently outperformed the "Flat" (standard cross-entropy) and $\ell_2$ baselines on "target" accuracy—the model's ability to classify fine-grained labels it didn't see during the initial training phase.
  • Robustness: The method proved robust across various architectures (ResNets and Vision Transformers) and batch sizes.

Limitations and Future Work

While highly effective, the authors note a few areas for further exploration:

  • Hierarchy Quality: The method relies on a pre-defined label hierarchy. If the provided tree is noisy or doesn't reflect visual similarity (e.g., a purely semantic WordNet tree), the benefits may be limited.
  • Batch Size Sensitivity: Like many OT-based methods, the quality of the distribution estimate depends on having enough samples per batch. While FastFT performs well even at standard batch sizes, extremely small batches might hinder the "distribution-to-distribution" matching.
  • Future Directions: The authors suggest investigating how their greedy matching approach could be applied to other areas of OT research beyond hierarchical learning.

For those interested in the implementation, the code is available on GitHub.

Summary updated

BibTeX
@inproceedings{zeng2025learning,
  author = {Siqi Zeng and Sixian Du and Makoto Yamada and Han Zhao},
  title = {{Learning Structured Representations by Embedding Class Hierarchy with Fast Optimal Transport}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=AnL6BuWzxa},
}
Figure