Papers
Topics
Authors
Recent
Search
2000 character limit reached

CosFace Loss: Additive Cosine Margin

Updated 12 July 2026
  • CosFace Loss is a normalized softmax-based objective that constrains both features and classifier weights on a hypersphere, enforcing an additive cosine margin.
  • It eliminates radial variation to align training with cosine similarity, ensuring a strict gap of at least m between target and non-target class logits.
  • Highly effective yet sensitive to hyperparameter choices, CosFace has inspired adaptations across face recognition and cross-modal retrieval tasks.

Searching arXiv for recent and foundational papers on CosFace and closely related variants. CosFace Loss, introduced in “CosFace: Large Margin Cosine Loss for Deep Face Recognition” as Large Margin Cosine Loss (LMCL), is a normalized softmax-based classification objective in which both features and classifier weights are constrained to a hypersphere and the target-class cosine logit is reduced by a fixed additive margin. The design aligns training with cosine-similarity-based verification and identification, which is the dominant inference geometry in modern face recognition (Wang et al., 2018). In later comparative literature, the same method is frequently discussed under the name Additive-Margin Softmax Loss (AM-Softmax) (Srivastava et al., 2019).

1. Formal definition and nomenclature

The original formulation starts from the standard softmax classifier, with class logit

fj=WjTxi+bj,f_j = W_j^T x_i + b_j,

and cross-entropy loss

Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.

CosFace rewrites this classifier in normalized angular form by imposing

Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,

normalizing the feature, and rescaling it by a fixed constant ss. The normalized logit becomes

fj=scosθj,i,f_j = s\cos\theta_{j,i},

where θj,i\theta_{j,i} is the angle between the sample feature and class weight. CosFace then modifies only the target-class logit: fyi=s(cosθyi,im),fj=scosθj,i    (jyi).f_{y_i} = s(\cos\theta_{y_i,i}-m),\qquad f_j = s\cos\theta_{j,i}\;\;(j\neq y_i). The resulting loss is

LLMCL=1Ni=1Nloges(cosθyi,im)es(cosθyi,im)+jyiescosθj,i.L_{\mathrm{LMCL}}= -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{s(\cos\theta_{y_i,i}-m)}} {e^{s(\cos\theta_{y_i,i}-m)}+\sum_{j\neq y_i}e^{s\cos\theta_{j,i}}}.

Here m0m\ge 0 is the additive cosine margin and ss is the scale factor (Wang et al., 2018).

Comparative work consistently identifies this same objective as AM-Softmax. In that naming, CosFace is the case in which the target logit is replaced by Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.0 while all non-target logits remain Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.1, and all cosine logits are scaled by Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.2 before softmax (Srivastava et al., 2019). The two names therefore refer to the same normalized additive-cosine-margin construction.

2. Hyperspherical geometry and decision boundaries

The geometric premise of CosFace is that deep face recognition should be governed by angular relations rather than Euclidean norm magnitude. By Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.3-normalizing both features and class weights, CosFace removes radial variation and constrains optimization to a hypersphere. This is important because test-time matching is typically based on cosine similarity between embeddings rather than raw inner products (Wang et al., 2018).

Under normalized softmax, the binary decision boundary is

Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.4

CosFace makes this boundary stricter. For two classes Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.5 and Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.6, the class-conditional requirements become

Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.7

Equivalently, the target cosine must exceed the competing cosine by at least Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.8. This directly enforces tighter intra-class angular concentration and larger inter-class separation on the hypersphere (Wang et al., 2018).

Later work sharpened the interpretation of this boundary. GB-CosFace characterized ordinary CosFace as a relative inter-class boundary: training pushes the target score above competing class scores, especially the largest non-target score, whereas open-set verification at test time compares two embeddings against a global threshold. In that view, CosFace remains highly effective, but it still inherits the closed-set multiclass structure of softmax training (Liu et al., 2021).

The same hyperspherical interpretation also explains why CosFace transfers naturally beyond canonical face verification. In VMCML, for example, CosFace is used as the “cross-modality lifting loss” that places video and music embeddings in a shared hyperspherical space, again because cosine similarity is the downstream retrieval criterion (Lee et al., 2023).

3. Scale, margin, and optimization behavior

CosFace has two central hyperparameters: the scale Ls=1Ni=1Nlogefyij=1Cefj.L_s = -\frac{1}{N}\sum_{i=1}^N \log \frac{e^{f_{y_i}}}{\sum_{j=1}^C e^{f_j}}.9 and the additive cosine margin Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,0. The scale is required because cosine values lie in a bounded interval, so normalized logits are otherwise too small for effective softmax optimization. The original paper derives a lower bound for Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,1,

Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,2

where Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,3 is the expected minimum posterior probability at a class center. In experiments, the paper fixes

Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,4

and reports that performance improves as Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,5 increases, saturates around

Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,6

and fails to converge when

Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,7

in its setup (Wang et al., 2018).

The same sensitivity was later analyzed in detail by AdaCos. That work argues that both Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,8 and Wj=1,bj=0,\|W_j\| = 1,\qquad b_j = 0,9 modulate the mapping from cosine similarity to predicted class probability: too small a scale prevents probabilities from becoming confident enough, while too large a scale can make the loss insensitive; too small a margin weakens supervision, and too large a margin can make convergence difficult (Zhang et al., 2019). AdaCos therefore treats CosFace as a strong but hyperparameter-sensitive member of the cosine-softmax family.

Comparative studies support this interpretation. The 2019 benchmark paper on face-recognition losses reports that AM-Softmax is consistently among the strongest losses, usually second only to ArcFace and occasionally best in a specific setting, but it does not provide the exact CosFace-specific ss0 and ss1 values used in its own experiments (Srivastava et al., 2019). In other words, CosFace is both simple and effective, but its behavior remains materially dependent on scale-margin calibration.

4. Position within the margin-softmax family

CosFace sits in the core lineage of hyperspherical margin losses for face recognition. The principal distinctions are in where the margin is injected.

Loss Target transformation Paper characterization
Softmax ss2 No explicit margin
SphereFace ss3 Multiplicative angular margin
CosFace ss4 Additive cosine margin
ArcFace ss5 Additive angular margin

This progression is presented explicitly in comparative work and in later papers that extend the family (Srivastava et al., 2019).

Several subsequent losses reinterpret or generalize CosFace rather than discard it. GB-CosFace introduces an adaptive global boundary ss6 and proves that CosFace is a special case obtained at ss7; in its rewritten form, that special case is equivalent to CosFace with margin ss8 and scale ss9 (Liu et al., 2021). ElasticFace-Cos replaces CosFace’s fixed additive margin with a Gaussian-sampled random margin fj=scosθj,i,f_j = s\cos\theta_{j,i},0, and reduces exactly to CosFace when fj=scosθj,i,f_j = s\cos\theta_{j,i},1 (Boutros et al., 2021). Q-Margin moves the margin from direct logit modification into the reference measure of an fj=scosθj,i,f_j = s\cos\theta_{j,i},2-divergence loss and recovers CosFace in the limit fj=scosθj,i,f_j = s\cos\theta_{j,i},3 (Koutsianos et al., 30 Jun 2026).

Other work critiques CosFace from a more geometric or adaptive-margin perspective. ExpFace treats CosFace as a uniform downward shift of the target similarity curve, emphasizing that its penalty is constant in similarity space and that the maximum of its gradient curve remains at fj=scosθj,i,f_j = s\cos\theta_{j,i},4 as the margin changes (Zheng et al., 24 Sep 2025). X2-Softmax argues that fixed-margin methods such as CosFace are mismatched to imbalanced class geometry and proposes an adaptive angular margin based on a quadratic target-logit function (Xu et al., 2023). Across these developments, CosFace remains the reference additive-cosine baseline against which newer geometric, probabilistic, or adaptive constructions are defined.

5. Adaptations, hybrids, and non-face deployments

Although introduced for deep face recognition, CosFace has been adapted in several distinct ways without altering its core additive-cosine-margin structure. MultiFace applies CosFace independently to multiple low-dimensional sub-features and sums the branch losses; it reports that MultiFace accelerates training by about fj=scosθj,i,f_j = s\cos\theta_{j,i},5–fj=scosθj,i,f_j = s\cos\theta_{j,i},6 with ArcFace or CosFace while improving benchmarks such as MegaFace and IJB (Xu et al., 2021). SubFace instead approximates full-feature training by randomly selected normalized subspaces; in its unified implementation, CosFace corresponds to the additive-cosine case fj=scosθj,i,f_j = s\cos\theta_{j,i},7, although the paper concludes that ArcFace generally outperforms CosFace under the same subspace strategy (Xu et al., 2022).

CosFace has also been transplanted beyond face recognition. VMCML uses a shared prototype matrix for both video and music embeddings and defines a “cross-modality lifting loss”

fj=scosθj,i,f_j = s\cos\theta_{j,i},8

thereby adapting CosFace from face identities to video–music correspondence classes in a shared hyperspherical space (Lee et al., 2023). In text-independent speaker identification, a modified VGG16 with fj=scosθj,i,f_j = s\cos\theta_{j,i},9-dimensional θj,i\theta_{j,i}0-normalized embeddings is trained with CosFace using θj,i\theta_{j,i}1 and θj,i\theta_{j,i}2, and the paper reports the best result of θj,i\theta_{j,i}3 top-1 accuracy on VoxCeleb1, ahead of ArcFace and Softmax in that setup (Garcia et al., 26 Sep 2025).

Within face-recognition systems, CosFace has also served as a modular building block rather than the final method. IronMask uses CosFace embeddings as normalized angular templates inside a protection architecture based on orthogonal transforms and real-valued ECC; the paper reports that CosFace is compatible with this protection scheme, but suffers larger degradation than ArcFace unless a centering step is added (Kim et al., 2021). UniTSFace combines CosFace with a unified-threshold integrated sample-to-sample loss, reporting clear gains over CosFace alone on MR-All and IJB-C while keeping the sample-to-class component (Li et al., 2023).

6. Empirical profile, limitations, and continuing development

The original CosFace paper reports that feature normalization is crucial and that LMCL outperforms softmax, center loss, triplet loss, and A-Softmax under matched settings. On CASIA-WebFace with normalized features, the paper reports LFW θj,i\theta_{j,i}4, YTF θj,i\theta_{j,i}5, MegaFace1 Rank-1 θj,i\theta_{j,i}6, and MegaFace1 Verification θj,i\theta_{j,i}7; with a larger training set, it reports LFW θj,i\theta_{j,i}8 and YTF θj,i\theta_{j,i}9 (Wang et al., 2018). These results established CosFace as a major practical alternative to earlier angular-margin losses.

Later comparisons give a more nuanced empirical picture. The 2019 loss-comparison study ranks ArcFace first overall and Additive-Margin Softmax second overall, but also reports a setting in which AM-Softmax is best: ResNet50 trained on MS-Celeb-1M reaches fyi=s(cosθyi,im),fj=scosθj,i    (jyi).f_{y_i} = s(\cos\theta_{y_i,i}-m),\qquad f_j = s\cos\theta_{j,i}\;\;(j\neq y_i).0 on LFW, slightly ahead of ArcFace in that particular experiment (Srivastava et al., 2019). Subsequent methods often improve over CosFace at stricter verification operating points: GB-CosFace reports gains on IJB-B and IJB-C, especially at very low FAR, and Q-Margin reports controlled improvements over CosFace and ArcFace baselines on IJB-B, IJB-C, and VoxCeleb in identical training recipes (Liu et al., 2021, Koutsianos et al., 30 Jun 2026).

The principal limitations attributed to CosFace in later literature are consistent. First, its fixed margin may be unrealistic when intra-class and inter-class variation are highly heterogeneous; this is the central motivation of ElasticFace and X2-Softmax (Boutros et al., 2021, Xu et al., 2023). Second, its closed-set multiclass training objective does not perfectly match open-set verification, where decisions are made using a global threshold on similarity rather than relative ranking among training classes (Liu et al., 2021). Third, its performance is materially influenced by manual tuning of fyi=s(cosθyi,im),fj=scosθj,i    (jyi).f_{y_i} = s(\cos\theta_{y_i,i}-m),\qquad f_j = s\cos\theta_{j,i}\;\;(j\neq y_i).1 and fyi=s(cosθyi,im),fj=scosθj,i    (jyi).f_{y_i} = s(\cos\theta_{y_i,i}-m),\qquad f_j = s\cos\theta_{j,i}\;\;(j\neq y_i).2, a point emphasized by AdaCos (Zhang et al., 2019). Fourth, several papers argue that generic margin losses, including CosFace, are less effective on hard samples than on easy ones, motivating distribution-level or quality-aware modifications such as DDL and LHfyi=s(cosθyi,im),fj=scosθj,i    (jyi).f_{y_i} = s(\cos\theta_{y_i,i}-m),\qquad f_j = s\cos\theta_{j,i}\;\;(j\neq y_i).3Face (Huang et al., 2020, Xie et al., 30 Jun 2025).

Taken together, these developments place CosFace in a distinctive position. It is the canonical additive-cosine-margin loss: simple, hyperspherical, easy to implement, and empirically strong across face recognition, speaker recognition, and even cross-modal retrieval. At the same time, much of the subsequent literature can be read as an extended attempt to preserve CosFace’s normalized cosine geometry while correcting its fixed-margin, fixed-scale, or closed-set limitations.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to CosFace Loss.