-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
add @adjoin for relu to increase speed #367
Conversation
findmyway
commented
Oct 9, 2019
This is useful, but you probably don't need the loop vs. just using another broadcast in the backwards pass. See also the gradients in |
This is neat. While you’re in there, perhaps add something similar for |
I have handwritten gradients for sigmoid, tanh and selu, as I needed those for one of my projects. Would it make sense to add those?
|
Thanks @findmyway! @pevnak yeah, those would be great to have as a PR. bors r+ |
367: add @adjoin for relu to increase speed r=MikeInnes a=findmyway ```julia using Flux, Zygote, BenchmarkTools x = rand(128) # before @benchmark gradient((x) -> sum(relu.(x)), $x) #= BenchmarkTools.Trial: memory estimate: 15.41 KiB allocs estimate: 425 -------------- minimum time: 9.980 μs (0.00% GC) median time: 10.649 μs (0.00% GC) mean time: 12.495 μs (4.12% GC) maximum time: 2.701 ms (98.24% GC) -------------- samples: 10000 evals/sample: 1 =# # after @benchmark gradient((x) -> sum(relu.(x)), $x) #= BenchmarkTools.Trial: memory estimate: 2.30 KiB allocs estimate: 3 -------------- minimum time: 258.013 ns (0.00% GC) median time: 303.099 ns (0.00% GC) mean time: 368.242 ns (16.51% GC) maximum time: 4.796 μs (85.99% GC) -------------- samples: 10000 evals/sample: 394 =# ``` Co-authored-by: Jun Tian <tianjun.cpp@gmail.com> Co-authored-by: Mike J Innes <mike.j.innes@gmail.com>
Build succeeded |
748: Speed up of selu r=DhairyaLGandhi a=racinmat Implementing speedup of selu based on this comment: #367 (comment) Utilizing vectorized ifelse based on https://github.com/FluxML/NNlib.jl/blob/master/src/activation.jl#L159. Co-authored-by: Matěj Račinský <matej.racinsky@avast.com>