# MFCosface: A Masked-Face Recognition Algorithm Based on Large Margin Cosine Loss
## 2 Related Work
### Softmax Loss Function  
Using a deep convolutional neural network (DCNN) for feature extraction for face representation is the preferred method of facial recognition [28,29]. DCNN performs a mapping operation on face images in a feature space with a small intra-class distance and a large inter-class distance. Some scholars trained a classifier based on the softmax loss function to separate different identities in the training set to solve the facial recognition problem. The softmax loss function is shown in Equation (1).  
\[L_{s}=-\frac{1}{N}\sum_{i=1}^{N}\log\frac{e^{W_{y}^{Tx}i+b_{yi}}}{\sum_{j=1}^{n }e^{W_{j}^{Tx}i+b_{j}}} \tag{1}\]  
Among them, \(x_{i}\in R^{d}\) represents the feature of the i-th sample, which belongs to the class \(y_{i}\). \(W_{j}\in R^{d}\) represents the \(j\) column of weight \(W\in R^{d\times n}\); \(b_{j}\in R^{n}\) is the deviation term; and the batch size and category are \(N\) and \(n\), respectively. The method based on the softmax loss function can be trained on large-scale training data and deep convolutional neural networks to obtain excellent facial recognition performance, but this method also has many shortcomings:  
1. The size of the linear transformation matrix \(W\in R^{d\times n}\) increases linearly with the number of identities \(n\). Since a \(W\in R^{d\times n}\) matrix is used to output n identity prediction probabilities, the number of identities n in the large-scale test set is usually very large, so the matrix \(W\) will show a linear increasing trend with \(n\), which will reduce the training efficiency of the model.
2. In the open-set facial recognition problem, a face cannot be fully distinguished. If a face image that has not been trained with before appears in the model recognition process, this method cannot distinguish it well, because the final output of the model does not include the probability of the identity never having appeared.
3. The softmax loss function does not explicitly optimize the characteristics of images to increase the similarity of the samples within the class and the diversity of the samples between the classes, which leads to a large number of appearance changes within each class. Hence, the performance for facial recognition is poor.  
In order to solve these problems, many scholars have improved the softmax loss function. [PERSON] et al. [30] proposed center loss, which can reduce the intra-class variance by optimizing the feature distance between the class center and the sample. [PERSON] et al. [31] proposed the large margin softmax (L-softmax) loss function, which adds an angle constraint to each sample by increasing the margin, which effectively expands the distance between classes and compresses the distance within classes. A-softmax [32] adds multiple restrictions to the angle in the L-softmax loss function, normalizes the weights, and provides a good geometric explanation by constraining the learning features to be distinguishable on the hyperspherical manifold. [PERSON] et al. [33] proposed large margin cosine loss (CosFace) to apply feature normalization and use the global scale factor s to replace the sample-related feature norm in A-softmax. CosFace converts the angular distance to the cosine distance to achieve the smallest intra-class variance and the largest inter-class variance possible, which effectively improves the recognition accuracy. [PERSON] et al. [34] proposed the Arcface facial recognition model, which improved AM-softmax and replaced the cosine distance with the angular distance. This method improves the loss based on softmax, and a large number of experiments have proved that it has superior recognition accuracy rates in facial recognition.