Git Product home page Git Product logo

mx-lsoftmax's Introduction

mx-lsoftmax

mxnet version of Large-Margin Softmax Loss for Convolutional Neural Networks.

Derivatives

I put all formula I used to calculate the derivatives below. You can check it by yourself. If there's a mistake, please do tell me or open an issue.

The derivatives doesn't include lambda in the paper, but the code does. Instead of using lambda to weight the original f_i_yi = |w_yi||x_i|cos(t), the code uses beta because lambda is a keyword for Python, but beta plays exactly the same role as lambda.

formula

Gradient Check

Gradient check can be failed with data type float32 but ok with data type float64. So don't afraid to see gradient check failed.

Operator Performance

I implement the operator both in Python and C++(CUDA). The performance below is training LeNet on a single GTX1070 with parameters margin = 4, beta = 1. Notice the C++ implement can only run on GPU context.

Batch Size traditional fully connected lsoftmax in Python lsoftmax in C++(CUDA)
128 ~45000 samples / sec 2800 ~ 3300 samples / sec ~40000 samples / sec
256 ~54000 samples / sec 3500 ~ 4200 samples / sec ~47000 samples / sec

Visualization

original softmax (traditional fully connected)

lsoftmax-margin-1

lsoftmax with margin = 2, beta = 100 and scale = 0.99

lsoftmax-margin-2

lsoftmax with margin = 3, beta = 100 and scale = 0.99

lsoftmax-margin-3

lsoftmax with margin = 4, beta = 100 and scale = 0.99

lsoftmax-margin-4

lsoftmax with margin = 6, beta = 1000 and scale = 0.99

lsoftmax-margin-6

References

mx-lsoftmax's People

Contributors

luoyetx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.