Inferensys

Glossary

Angular Margin Loss

A family of loss functions, including ArcFace and CosFace, that enforces discriminative constraints on the angular space of feature embeddings to maximize inter-class separation.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
DISCRIMINATIVE EMBEDDING LEARNING

What is Angular Margin Loss?

A family of loss functions that enforces discriminative constraints on the angular space of feature embeddings to maximize inter-class separation and intra-class compactness.

Angular Margin Loss is a class of loss functions that modifies the standard softmax cross-entropy objective by introducing an additive angular margin penalty between feature vectors and their corresponding class weight vectors. This geometric constraint forces the learned embeddings to be more discriminative by explicitly maximizing the decision boundary in the angular domain, rather than relying solely on Euclidean distance separation.

Prominent variants include ArcFace and CosFace, which normalize both the feature embeddings and the class weight vectors to lie on a hypersphere before applying the margin. This normalization eliminates radial variance, compelling the network to learn strictly from angular information. The resulting embeddings exhibit high intra-class compactness and inter-class discrepancy, making them robust for open-set tasks such as face verification and emitter identification where unknown classes must be rejected based on distance thresholds.

DISCRIMINATIVE FEATURE LEARNING

Key Variants of Angular Margin Loss

Angular margin loss functions enforce a multiplicative or additive margin in the angular space of feature embeddings, compelling the network to learn highly discriminative features with maximized inter-class separation and minimized intra-class variance.

01

SphereFace (A-Softmax)

The foundational angular margin loss that introduced a multiplicative angular margin to the standard SoftMax formulation. By projecting features onto a hypersphere and multiplying the angle by a margin parameter m, SphereFace forces the decision boundary to be more stringent, requiring features to be closer to their class center. This formulation directly optimizes for angular separability rather than Euclidean distance, making learned features more discriminative for open-set tasks. The key limitation is training instability at high margin values due to the non-monotonic nature of the multiplicative margin, which can cause the loss surface to become difficult to optimize without careful annealing strategies.

m ≥ 2
Typical Margin Parameter
02

CosFace (AM-Softmax)

Reformulates the angular margin as an additive cosine margin rather than a multiplicative one, dramatically improving training stability. CosFace normalizes both feature vectors and weight vectors, then subtracts a margin m directly from the cosine of the angle before scaling with a temperature parameter s. This additive approach creates a linear decision margin in cosine space that is easier to optimize. Key properties include:

  • Feature normalization ensures all samples lie on a hypersphere of radius s
  • Additive margin avoids the vanishing gradient issues of multiplicative approaches
  • Scale parameter s controls the radius of the hypersphere, typically set between 30 and 64
  • Directly applicable to open-set emitter recognition where unknown transmitters must fall below a cosine similarity threshold
s=64, m=0.35
Standard Hyperparameters
03

ArcFace (Additive Angular Margin)

The most widely adopted angular margin loss that applies an additive margin directly to the angle rather than the cosine. ArcFace computes the arccosine of the logit, adds a constant margin m to the target angle, then takes the cosine. This yields a constant linear angular margin throughout the entire angle range, providing exact geodesic distance constraints on the hypersphere. Advantages for RF fingerprinting include:

  • Exact angular interpretation: The margin directly corresponds to a minimum angular separation in radians
  • Superior convergence: The linear angular penalty produces cleaner gradient signals
  • Robustness to label noise: The constant margin is less sensitive to mislabeled training samples
  • Widely validated on large-scale face recognition benchmarks with millions of identities
m=0.5 radians
Typical Angular Margin
04

AdaCos (Adaptive Cosine Scaling)

An automated hyperparameter-free variant that dynamically adjusts the scale parameter s during training based on the observed distribution of cosine similarities. AdaCos eliminates the need for manual tuning of the scale and margin parameters, which is critical when deploying angular margin loss across diverse emitter recognition tasks with varying numbers of device classes. The method analyzes the expected and observed probability distributions of the SoftMax output to compute an optimal scale at each training step. This self-calibrating property makes it particularly suitable for few-shot device enrollment scenarios where hyperparameter sweeps are impractical due to limited training data per emitter.

0
Manual Hyperparameters
05

MV-SoftMax (Misclassified Vector Guidance)

Extends angular margin loss by explicitly emphasizing hard negative classes during training. MV-SoftMax identifies the non-target class with the highest cosine similarity to a sample and applies an additional penalty to push the feature vector away from that specific class center. This targeted repulsion mechanism is valuable for open-set emitter recognition where certain device classes may have nearly identical hardware impairments, creating confusable class pairs. By focusing the margin on the most challenging negative class rather than applying a uniform margin, MV-SoftMax achieves finer separation between similar transmitters without unnecessarily distorting the embedding space for well-separated classes.

Hard Negative Mining
Core Mechanism
06

CurricularFace (Adaptive Margin)

Introduces a curriculum learning strategy to angular margin training, where the margin emphasis shifts from easy positive samples early in training to hard negative samples later. In early epochs, CurricularFace behaves like standard CosFace to establish basic class structure. As training progresses, it adaptively increases the importance of difficult negative samples, mimicking the effect of hard negative mining. This prevents the network from collapsing in early training due to overly aggressive margins while still achieving tight class boundaries at convergence. For RF fingerprinting, this approach handles the wide variance in signal quality across different collection environments by gradually increasing discriminative pressure.

Positive → Hard Negative
Emphasis Shift
ANGULAR MARGIN LOSS

Frequently Asked Questions

Explore the mechanics behind angular margin loss functions like ArcFace and CosFace, which enforce discriminative constraints on feature embeddings to maximize inter-class separation in open set emitter recognition.

Angular Margin Loss is a family of loss functions that enforces discriminative constraints on the angular space of feature embeddings rather than Euclidean distance. Unlike traditional SoftMax loss, which separates classes but does not explicitly maximize inter-class margins, angular margin losses—such as ArcFace and CosFace—introduce an additive or multiplicative margin penalty to the angle between feature vectors and their corresponding class weight vectors. The core mechanism involves normalizing both the feature embeddings and the classifier weights to lie on a hypersphere, then computing the cosine of the angle between them. A margin m is added to the target angle, forcing the network to produce more compact intra-class clusters and wider inter-class separations. This geometric constraint is particularly valuable in open set emitter recognition, where unknown transmitters must be rejected based on their distance from known class prototypes in the embedding space.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.