/Proj_Centroid_Loss_LeNet/README.md

https://github.com/episodeyang/deep_learning_notes · Markdown · 48 lines · 33 code · 15 blank · 0 comment · 0 complexity · f409f9378dd30fba45515e82a1c7432a MD5 · raw file

  1. # LeNet_plus_centerloss README
  2. @episodeyang 2016.
  3. This is a Tensorflow implementation Yandong Wen's paper with a novel contrastive loss function
  4. [link](http://ydwen.github.io/papers/WenECCV16.pdf).
  5. In this paper, Wen *et.al.* attempt to achieve stronger inter-class differentiation by using a
  6. novel loss function that penalizes intra-class spread. Here I attempt to replicate some of the
  7. results with a LeNet implemented in Tensorflow.
  8. ## Learnings
  9. - **2D feature embedding** The paper uses a very nice 2-D embedding for the feature layer. This makes an interesting
  10. visualization, and can be seen in this figure bellow. Each color corresponds to a different
  11. class label.
  12. <img width="400" height="322" alt="2 D Deep Features" src="LeNet_plus_centerloss/figures/MNIST%20LeNet%2B%2B%20with%202%20Deep%20Features%20(PReLU).png"/>
  13. - **Usage of PReLU** The paper uses PReLU activation function. At the time I used Xavier initialization,
  14. but He initialization would be more appropriate.
  15. - **Evolution of embedding** Curious about the evolution of the network, I made a few videos showing
  16. how the embedding evolves during training. You can find a few here [here](LeNet_plus_centerloss/figures/animation/)
  17. <p align="center">
  18. ![network learning](LeNet_plus_centerloss/figures/animation/MNIST_LeNet_centroid_loss_lambda_0.001.gif)
  19. </p>
  20. ## Usage
  21. To **train** run:
  22. ```shell
  23. python3 ./LeNet_plus_centerloss/MNIST_train.py
  24. ```
  25. To **evaluate** run:
  26. ```shell
  27. python3 ./LeNet_plus_centerloss/MNIST_eval.py
  28. ```
  29. ### Prerequisite
  30. Have Tensorflow installed, with GPU support.
  31. **NOTE** In order for the eval script to run at the same time as the
  32. training, you would need to have multiple devices (GPUs), or share the
  33. same CPU (will be slow).