Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add PReLU activation? #17

Open
cooltopics opened this issue Apr 10, 2020 · 3 comments
Open

How to add PReLU activation? #17

cooltopics opened this issue Apr 10, 2020 · 3 comments

Comments

@cooltopics
Copy link

I need to add PReLU activation which has a learn-able parameter? What would be the best way to extend this library in this respect?
thanks.

@cooltopics
Copy link
Author

Similarly, I find difficulty to even add a leakyReLU layer.

@yixuan
Copy link
Owner

yixuan commented Apr 12, 2020

In this case you need to define an ordinary layer that computes the derivative of the parameter, which is not an easy task since derivatives are coded manually.

@Hykni
Copy link

Hykni commented Aug 28, 2020

A vanilla leakyReLU activation would be very simple to add, copy the code from Activation/ReLU.h and replace the activation&gradient for Z<0...
i.e.
A.array() = Z.array().cwiseMax(Scalar(0));
to
A.array() = (Z.array() > Scalar(0)).select(Z, Z.array() * Scalar(p));
and
G.array() = (A.array() > Scalar(0)).select(F, Scalar(0));
to
G.array() = (A.array() > Scalar(0)).select(F, Scalar(p));
where p would be your leaky gradient for Z<0. Not really sure if the first replacement is valid eigen code but you should understand the concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants