A Coding-Theoretic Analysis of Hyperspherical Prototypical Learning Geometry

Martin Lindström, Borja Rodríguez-Gálvez, Ragnar Thobaben, Mikael Skoglund

TL;DR

This paper bridges the gap between coding theory and representation learning to optimize Hyperspherical Prototypical Learning (HPL). By leveraging binary linear block codes and a novel convex relaxation, the authors provide a principled way to design class prototypes with near-optimal separation across a wide range of dimensions, significantly improving flexibility and performance in low-dimensional latent spaces.

What Problem Does This Paper Address?

In supervised representation learning, "prototypes" are fixed vectors representing each class. HPL places these prototypes on a unit hypersphere, which provides a scale-invariant geometry that helps the model learn better class separation.

However, finding the best way to arrange $K$ prototypes on an $n$-dimensional sphere to maximize their distance—a variation of the classic "Tammes problem"—is computationally hard (non-convex and combinatorial). Previous methods were either heuristic and unprincipled or restricted to the specific case where the dimension $n$ equals $K-1$. This paper tackles the challenge of finding well-separated prototypes for any dimension $n < K$, providing both a theoretical framework and practical construction methods.

Methods

The authors introduce two primary strategies for prototype design:

  1. Coding-Theoretic Prototypes: They utilize binary linear block codes (like BCH and Reed-Muller codes) from classical communication theory. By mapping binary codewords from Hamming space to the hypersphere, they can guarantee specific separation properties. A high Hamming distance between binary strings directly translates to a low cosine similarity (better separation) on the sphere.
  2. Log-Sum-Exp Relaxation ($P_{LSE}$): For optimization-based approaches, the authors propose a new convex relaxation using the log-sum-exp function. Unlike previous methods that minimized average similarity, $P_{LSE}$ acts as a smooth approximation of the maximum function, allowing the optimizer to focus on the "worst-case" pair of prototypes and push them further apart.
Visualizing how different encodings place prototypes on a 3D sphere. Code-based methods (right) achieve much better separation than naive one-hot encoding (left).

Datasets

The proposed methods were evaluated on standard image classification benchmarks:

  • CIFAR-100: 100 classes of natural images.
  • MNIST: 10 classes of handwritten digits.

The authors focused on how prototype separation correlates with final model accuracy across different latent dimensions ($n$).

Key Insights and Ideas

  • The Hamming-Sphere Bridge: The mapping $c = \frac{2(b - 1/2)}{\sqrt{n}}$ is a powerful tool. It allows researchers to tap into decades of error-correcting code research to solve geometric problems in machine learning.
  • Dimension Compression is Viable: You don't need a high-dimensional space to separate many classes. The authors show that near-orthogonal prototypes can be achieved even when the dimension $n$ is roughly half the number of classes ($n \approx K/2$).
  • Theoretical Guardrails: By deriving achievable (Gilbert-Varshamov) and converse (Rankin) bounds, the paper establishes exactly how much separation is mathematically possible, showing that their proposed methods are nearly as good as any theoretical ideal.
  • The Semantic Gap: A crucial "aha" moment in the paper is that separation isn't everything. If two semantically similar classes (e.g., "lion" and "leopard") are randomly mapped to prototypes that are diametrically opposite, the model struggles. The alignment between semantic similarity and geometric separation is a key factor in accuracy.

Key Results

  • Near-Optimal Separation: The $P_{LSE}$ optimization and specific code-based constructions (like BCH) consistently hit or approach the theoretical converse bound for separation.
  • Performance in Low Dimensions: On CIFAR-100, BCH-code-based prototypes outperformed existing optimization methods in compressed dimensions ($n < 100$).
  • Thresholding Effect: The experiments revealed a thresholding effect around $n=K$; adding more dimensions beyond the number of classes yields diminishing returns for both separation and accuracy.
Figure 2. Maximum pairwise cosine similarity of K = 100 pro- totypes in various latent space dimensions (logarithmic scale). Coding-theoretic approaches provide additional flexibility over the Kasarla et al. (2022) mapping. The optimisation-based (PLSE) pro- totypes achieve slightly better separation than the (PAVG) scheme. All schemes (except for RM codes with n = 32) fall within the achievable and converse bounds from Theorem 3.5. For large n, the BCH, RM, and (PAVG) prototypes yield no worse than othog- onal prototypes. The (PLSE) and Kasarla et al. (2022) prototypes achieve the converse bound and perform therefore slightly better.
Figure 4. Top-1 accuracy results for CIFAR-100 for different pro- totype generation schemes, averaged over 5 runs, with errorbars corresponding to one standard deviation.

Limitations and Future Work

  • Semantic Agnosticism: The current code-based approach assigns prototypes to classes arbitrarily. The authors noted that accuracy drops when semantically similar classes are forced to be geometrically distant.
  • Future Direction: A major next step is developing methods to incorporate semantic data (e.g., from word embeddings or hierarchy trees) into the prototype assignment process so that "lion" and "leopard" prototypes are close, but still well-separated from "truck."
  • Self-Supervised Learning: The authors suggest exploring how these geometric inductive biases could improve self-supervised learning schemes, where class labels aren't available during initial training.

Summary updated

BibTeX
@inproceedings{lindstrom2024coding,
  author = {Martin Lindström and Borja Rodríguez-Gálvez and Ragnar Thobaben and Mikael Skoglund},
  title = {{A Coding-Theoretic Analysis of Hyperspherical Prototypical Learning Geometry}},
  booktitle = {GRaM @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=SEJacmw893},
}
Figure