BrainJS / brain.js

🤖 GPU accelerated Neural networks in JavaScript for Browsers and Node.js
https://brain.js.org
MIT License
14.32k stars 1.07k forks source link

Feature Request: Add Mish activation #484

Open digantamisra98 opened 4 years ago

digantamisra98 commented 4 years ago

Mish is a new novel activation function proposed in this paper. It has shown promising results so far and has been adopted in several packages including:

All benchmarks, analysis and links to official package implementations can be found in this repository

It would be nice to have Mish as an option within the activation function group.

This is the comparison of Mish with other conventional activation functions in a SEResNet-50 for CIFAR-10:
se50_1

extremety1989 commented 4 years ago

function mish(x) { return x * (Math.exp(Math.log(1 + Math.exp(x))) - Math.exp(-Math.log(1 + Math.exp(x))))/(Math.exp(Math.log(1 + Math.exp(x))) + Math.exp(-Math.log(1 + Math.exp(x)))); }

function derivativeOfMish(y) { let omega = Math.exp(3 y)+4 Math.exp(2 y) + (6+4 y) Math.exp(y) + 4 (1 + y); let delta = 1 + Math.pow((Math.exp(y) + 1), 2); return Math.exp(y) * omega / Math.pow(delta, 2); }

extremety1989 commented 4 years ago

Can you please add mish function,that i provided, i already tested it on my custom neural network and it works great,better than sigmoid and tanh ! on XOR

mubaidr commented 4 years ago

That sounds great. Would love to see as contributor though.

robertleeplummerjr commented 4 years ago

Keep in mind we have the GPU implementations as well.

extremety1989 commented 4 years ago

@mubaidr how can i apply this function as contributor?

digantamisra98 commented 4 years ago

@extremety1989 are you planning to submit a PR?

extremety1989 commented 4 years ago

@digantamisra98 no, sometimes it returns NaN when learning rate is 0.1, i do not know what is the probleme,maybe javascript

digantamisra98 commented 4 years ago

@extremely1989 Mish has a Softplus operator which needs proper threshold to fix that NaN issue you might be facing.

extremety1989 commented 4 years ago

@digantamisra98 my threshold is 0.5, i how much should i turn ?

digantamisra98 commented 4 years ago

@extremety1989 the Softplus operator thresholds that Tensorflow use is in the range of [0,20]