ArcFace loss is widely used in face recognition and image classification. In this tutorial, we will introduce some important things you must notice when using it.
We will use it for MNIST classification.
ArcFace loss
It is defined as:
In order to use this loss, we should determine the value of s and m.
How to determine s and m?
From some experiments we can find:
The value of s and m should determined by image feature dimension.
For example, if the image feature is 1*512, which means the image feature dimension is 512.
s and m can be 64 and 0.5
It means s = 64 and m = 0.5
However, if the image feature is 1*512, we need use t-SNE to convert it to 2D point.
from sklearn.manifold import TSNE tsne_2D = TSNE(n_components=2, init='pca', random_state=0) result_2D = tsne_2D.fit_transform(x)
We will see an image as follows:
If you want to see arcface loss effect as follows:
We need make the feature is 2D dimension (1*2). At this situation, s and m can be 10.0 and 0.2
It means s = 10.0 and m = 0.2
If you still use 64 and 0.5, we will get worse effect when the feature is 2D dimension.