![license](https://camo.githubusercontent.com/5e0e090b7e2a12f1b4b49710c10cb6b5bcf132720e3c1ba8c2d0c50af9e5d70c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e7376673f6d61784167653d32353932303030)
This is a quick implementation for Deep Hypersphere Embedding for Face Recognition(CVPR 2017).This paper proposed the angular softmax loss that enables convolutional neural networks(CNNs) to learn angularly discriminative features. The main content I replicated contains:
- 1. mathematical comparison among original softmax, modified softmax and angular softmax;
- 2. show the accuracy and loss comparison of different softmax in the experiment;
- 3. 2D and 3D visualization of embeddings learned with differnet softmax loss on MNIST dataset;
- 4. I replicated SphereFace-20 model with tensorflow.and here is code and graph.
many current CNNS can viewed as convolution feature learning guided by softmax loss on top. however, softmax is easy to to optimize but does not explicitly encourage large margin between different classes.
on this situation, the author proposed a new loss function that always encourages an angular decision margin between different classes.
softmax |
formula |
test acc(MNIST) |
original softmax |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/original_softmax.png?raw=true) |
0.9775 |
modified softmax |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/modified_softmax.png?raw=true) |
0.9847 |
angular softmax |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/angular_softmax.png?raw=true) |
0.9896 |
A toy example on MNIST dataset, CNN features can be visualized by setting the output dimension as 2 or 3, as shown in following figures.
original softmax |
modified softmax |
angular softmax |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/2D_Original_Softmax_Loss_embeddings.gif?raw=true) |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/2D_Modified_Softmax_Loss_embeddings.gif?raw=true) |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/2D_Angular_Softmax_Loss_embedding.gif?raw=true) |
original softmax |
modified softmax |
angular softmax |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/3D_Original_Softmax_Loss_embeddings.gif?raw=true) |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/3D_Modified_Softmax_Loss_embeddings.gif?raw=true) |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/3D_Angular_Softmax_Loss_embeddings.gif?raw=true) |
training loss |
training accuracy |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/train_loss.jpg?raw=true) |
![weibo-logo](https://github.com/YunYang1994/SphereFace/raw/master/image/train_acc.jpg?raw=true) |