SphereFace is a loss function that normalizes the weights of the final fully connected classification layer to unit length and multiplies the angle between the target-class weight and the feature by , creating an angular gap (margin) between classes. The loss itself is called the A-Softmax (angular softmax) loss, and the face features learned with it are called SphereFace. It was proposed by Liu et al. in 2017 for face recognition.
With denoting the angle between the weight of the target class and the feature , the A-Softmax loss is given by the following equation ( is the number of training examples and is the angle to the weight of class ).
is a function equal to for (details in the next section). Compared with without a margin, only the target-class logit becomes smaller, so the angle must be smaller for the prediction to count as correct.
The motivation lies in the difference between two uses of face recognition.
- Distinguishing only people seen in training (closed set): If every test identity appears in the training data, the task can be solved as ordinary classification.
- Distinguishing people unseen in training (open set): Real face verification is this case: the features of two face images are compared to decide whether they belong to the same person. Ideally, the maximum distance between features of the same person is smaller than the minimum distance to a different person.
Training classification with cross-entropy alone (which the paper calls the softmax loss) separates the features but does not push them far enough apart to meet this condition. Earlier methods added Euclidean-distance margins, as in Contrastive Loss, Triplet Loss, and Center loss. The paper showed that features learned with the softmax loss are inherently spread radially from the origin (by angle), and argued that it is natural to put the margin on the angle rather than on Euclidean distance.
The left side of the figure at the top places two class weights and 90° apart and shades which class each direction on the circle is assigned to. With , a 54° band between and is assigned to neither class.


