Mxnet Center Loss Save

implement center loss operator for mxnet

Project README


This is a simple implementation of the center loss introduced by this paper : 《A Discriminative Feature Learning Approach for Deep Face Recognition》,Yandong Wen, Kaipeng Zhang, Zhifeng Li, and Yu Qiao, Shenzhen check their site



install mxnet

for visualization, you may have to install seaborn and matplotlib

sudo pip install seaborn matplotlib


  • implementation of the operator and custom metric of the loss
  • custom MNIST iterator, output 2 labels( one for softmax and one for center loss
  • copied from mxnet example with some modification
  • script to train the model
  • script to visualise the result

running the tests

1 set path of mxnet

change mxnet_root to your mxnet root folder in

2 train

  • with cpu

    python --batch-size=128

  • with gpu

    python --gpus=0

    or multi device( not a good idea for MNIST example here )

    python --gpus=0,1 --batch-size=256

then you can see the output by typing

tail -f log.txt

3 visualize the result



You will see something like right picture... Now compare it with the 'softmax only' experiment in left, all the samples are well clustered, therefor we can expect better generalization performance. But the difference is not fatal here(center loss does help with convergence, see the last figure), since the number of classes is actually the same during train and test stages. For other application such as face recognition, the potential number of classes is unknown, then a good embedding is essential.


training log:


Open Source Agenda is not affiliated with "Mxnet Center Loss" Project. README Source: YYuanAnyVision/mxnet_center_loss
Open Issues
Last Commit
6 years ago

Open Source Agenda Badge

Open Source Agenda Rating