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

Generalize activation functions to complex input #132

Open
PhilipVinc opened this issue Sep 14, 2019 · 3 comments
Open

Generalize activation functions to complex input #132

PhilipVinc opened this issue Sep 14, 2019 · 3 comments

Comments

@PhilipVinc
Copy link

Hi,

I would find it useful if the activation functions where generalised to handle complex inputs. Many of them are still well-defined in this case, for example, there is no reason for sigmoid to be limited to real values, and it could be easily generalized.

σ(x::Real) = one(x) / (one(x) + exp(-x))
swish(x::Real) = x * σ(x)

softplus is also mathematically well defined, but for an efficient implementation someone with more experience than me could comment on how to rewrite it

softplus(x::Real) = ifelse(x > 0, x + log1p(exp(-x)), log1p(exp(x)))

The main advantage for this is that people like me working with complex-valued neural networks (often encountered in physics) could depend on NNlib and get the GPU versions of those functions with no effort.

Would you accept a PR (and a complimentary PR to CuArrays.jl) for that?

@MikeInnes
Copy link
Member

I don't think there's any good reason for this beyond us not thinking of it at the time. So please do send a PR!

@PhilipVinc
Copy link
Author

Great, thanks!

I noticed that in #118 (@devmotion) you were considering using the implementations of some activation functions from StatsFun .
As the PR is somewhat stale, is it still under consideration, or I can safely make a PR to NNlib?

@MikeInnes
Copy link
Member

Yes, it's unfortunate that PR got missed, but since it needs a rebase anyway you may as well just PR against master.

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

2 participants