Learning Towards The Largest Margins

Xiong Zhou, Xianming Liu, Deming Zhai, Junjun Jiang, Xin Gao, Xiangyang Ji

Introduction

In deep learning, a primary goal of classification models is to learn "discriminative" features. Ideally, samples from the same class should cluster tightly together (intra-class compactness), while different classes should be pushed as far apart as possible (inter-class separability).

While the standard Softmax loss is highly effective for classification, it does not explicitly enforce these geometric margins. To address this, researchers have previously developed popular variants like SphereFace, CosFace, and ArcFace. However, these were largely developed through geometric intuition and heuristics rather than rigorous mathematical principles. There has been no clear theoretical guarantee explaining why certain tricks—like feature normalization—are necessary, or how to optimally adapt these losses for difficult scenarios like imbalanced datasets.

This paper moves beyond heuristic "margin-based" loss functions by providing a rigorous mathematical framework for learning towards the largest margins. The authors introduce a principled approach to maximize both inter-class separability and intra-class compactness, resulting in new tools like the Largest Margin Softmax (LM-Softmax) and simple regularization terms that significantly boost performance across various vision tasks.

Formalizing the Margins

The authors formalize the problem by defining two key metrics:

  1. Class Margin: The minimal pairwise angle between class "prototypes" (the weight vectors representing each class).
  2. Sample Margin: The difference in similarity between a sample and its own class prototype versus the nearest prototype of another class.
Evolution of Test Accuracy, Class Margin, and Sample Margin

Key Contributions: * Theoretical Proofs: The authors prove that maximizing the minimal sample margin across a dataset naturally leads to the maximum possible class margin, regardless of feature dimensions or class balance. * GM-Softmax: A "Generalized Margin" framework that encompasses existing losses as special cases, allowing for a unified theoretical analysis. * LM-Softmax (Largest Margin Softmax): A novel, simplified loss function derived directly from the goal of maximizing the minimal sample margin. * Regularization Terms: * Sample Margin Regularization ($R_{sm}$): A plug-and-play term to help standard losses achieve larger margins. * Zero-Centroid Regularization ($R_w$): A simple but effective tool designed specifically to combat class imbalance by forcing the average of class prototypes to zero.

Key Insights

  • Normalization is Mandatory: The paper provides a theoretical proof that without normalizing both features and prototypes, the original softmax loss can result in an arbitrarily small class margin. This mathematically justifies why normalization has become a standard trick in the field.
  • The Geometry of Perfection: The optimal solution for class separation is shown to be a regular (k-1)-simplex (a higher-dimensional version of an equilateral triangle or tetrahedron). This connects their work to the recent popular concept of "Neural Collapse."
  • Simplicity Wins in Imbalance: For imbalanced data, simply ensuring the "centroid" of all class prototypes is zero ($R_w$) allows the model to maintain large margins even for minority classes, preventing majority classes from crowding out the feature space.

Results and Performance

The authors evaluated their methods across a massive range of benchmarks, including visual classification (MNIST, CIFAR), imbalanced classification, Person Re-Identification (ReID), and Face Verification.

Performance on Imbalanced CIFAR-10 and CIFAR-100
  • Classification: Adding Sample Margin Regularization ($R_{sm}$) to standard losses like CosFace or ArcFace consistently increased both the class margin and the final test accuracy. For example, on CIFAR-100, $R_{sm}$ improved ArcFace's class margin from ~76° to ~90°.
  • Imbalanced Learning: On long-tailed CIFAR-100, the proposed LM-Softmax with Zero-Centroid Regularization outperformed the specialized LDAM loss, improving accuracy from 43.28% to 45.28%.
  • Person ReID & Face Verification: LM-Softmax achieved state-of-the-art results on Market-1501 (84.7% mAP), proving more robust to hyper-parameter changes than previous margin-based losses. Furthermore, Zero-Centroid Regularization provided a notable boost to existing ArcFace and CosFace baselines on the challenging IJBC-C dataset.

Limitations and Future Work

While LM-Softmax is theoretically powerful, the authors note it can be less stable during training on severely imbalanced datasets without the addition of the Zero-Centroid Regularization.

Future work could explore applying these principled margin concepts to other domains beyond vision, such as natural language processing or multi-modal learning, where discriminative feature representation is equally critical. Additionally, investigating the dynamics of how these margins evolve during the early stages of training could lead to even more efficient optimization strategies.

Summary updated

BibTeX
@inproceedings{zhou2022learning,
  author = {Xiong Zhou and Xianming Liu and Deming Zhai and Junjun Jiang and Xin Gao and Xiangyang Ji},
  title = {{Learning Towards The Largest Margins}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=hqkhcFHOeKD},
}
Figure