Beyond one-hot encoding: Lower dimensional target embedding

Pau Rodríguez, Miguel Ángel Bautista, Jordi Gonzàlez, Sergio Escalera

TL;DR

This paper challenges the status quo of one-hot encoding in image classification by proposing lower-dimensional target embeddings. By using random projections or data-driven eigenrepresentations of the class manifold, the authors demonstrate drastically faster training convergence and competitive accuracy, especially in large-scale and fine-grained datasets.

What Problem Does This Paper Address?

In modern computer vision, one-hot encoding is the default way to represent labels. If you have 1,000 classes, your model outputs a 1,000-dimensional vector where only one element is "1" and the rest are "0."

However, this approach has two major flaws:

  1. Independence Assumption: It treats all classes as equally different (e.g., a "Husky" is as different from a "Malamute" as it is from a "Toaster"), ignoring the rich hierarchical relationships between labels.
  2. Gradient Sparsity: In large-scale datasets, most output neurons are inactive during a given training step. This leads to sparse, noisy gradient estimates, which significantly slows down convergence—especially when using small mini-batches.

The authors argue that labels actually lie on a low-dimensional manifold, and we can exploit this to make training more efficient.

Methods

The authors propose replacing the standard one-hot output layer with an Error-Correcting Output Code (ECOC) framework. Instead of predicting a sparse $n$-dimensional vector, the network predicts a dense $k$-dimensional "code" (where $k \ll n$).

They explore two main ways to generate these codes:

  • Random Projections (Data-Independent): Using random Gaussian matrices. Surprisingly, because high-dimensional random vectors tend toward orthogonality, these serve as a strong, zero-cost baseline that improves convergence speed.
  • Normalized Eigenrepresentation (Data-Dependent): This is the paper's more sophisticated contribution. They build a class similarity matrix and solve a Normalized Cut (NCut) problem. By taking the eigenvectors of the normalized Laplacian of this matrix, they create an embedding that naturally groups similar classes together.

To integrate this into a CNN, they introduce a decoder between the network's last hidden layer and the softmax function. This decoder computes the Euclidean distance between the predicted code and the target codewords in a "code matrix."

Datasets

The researchers validated their approach across several standard benchmarks:

  • ImageNet (ILSVRC 2012): 1.2M images across 1,000 object classes.
  • MIT Places-205: 2.5M images across 205 scene categories.
  • CIFAR-100: 60,000 small images across 100 classes.
  • CUB200-2011: A fine-grained dataset of 200 bird species, used to test how the method handles highly similar classes.

Key Insights and Ideas

  • Parameter Sharing via Dimensionality Reduction: By reducing the output space, the model is forced to share parameters across classes. This leads to more robust gradient estimates because more neurons are "useful" during every backpropagation step.
  • Small Mini-batch Resilience: One-hot encoding struggles with small mini-batches because the probability of seeing a specific class is low. The proposed embeddings allow the model to learn about the "structure" of the output space even when specific classes aren't present in a batch.
  • Semantic Manifolds: The data-dependent approach (eigenrepresentations) effectively "discovers" the taxonomy of the dataset. The first few bits of the code might distinguish between aquatic and non-aquatic birds, while later bits handle finer details.
  • Efficiency: On CUB200, the data-dependent codes achieved the same accuracy as one-hot encoding while using only 25% of the bits.

Key Results

  • Convergence Speed: On ImageNet and MIT Places, models using the proposed embeddings converged significantly faster than one-hot counterparts, particularly when the mini-batch size was small (e.g., 16 or 32).
  • Accuracy: On CIFAR-100, the data-dependent approach reached ~50% accuracy with 100 bits, outperforming random codes and matching one-hot performance while being more robust to "bit loss."
  • Fine-grained Classification: On the CUB200 bird dataset, the data-dependent codes significantly reduced confusion between visually similar species (like the "Fish Crow" and "Boat-tailed Grackle") compared to one-hot or random encoding.

Limitations and Future Work

  • Similarity Matrix Requirement: The data-dependent approach requires a pre-existing class similarity matrix. In this paper, the authors used features from a pre-trained model to build this matrix. For a completely new domain, generating this matrix might require an extra step or prior domain knowledge.
  • Hyperparameter Tuning: While the paper shows $k \ll n$ is effective, the optimal choice for the embedding dimension $k$ likely depends on the specific dataset's complexity and "intrinsic" dimensionality.
  • Future Directions: The authors suggest that exploring how these embeddings interact with even larger output spaces (e.g., hundreds of thousands of classes) could be a promising next step for extreme classification tasks.

Summary updated

BibTeX
@article{rodriguez2018beyond,
  author = {Pau Rodríguez and Miguel Ángel Bautista and Jordi Gonzàlez and Sergio Escalera},
  title = {{Beyond one-hot encoding: Lower dimensional target embedding}},
  journal = {Image and Vision Computing},
  year = {2018},
  url = {https://openreview.net/forum?id=sjlFg3S1vU},
}
Figure