You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thank you all for your work on ReverseDiff.
I'm not sure whether this issue belongs here on in the ChainRules repo, so forgive me if it's not relevant here.
I have tried defining my own pullback using ChainRules, which claims to be compatible with ReverseDiff.
However, my attempts so far have been unsuccesful.
As a minimal example, take
using ChainRules, ChainRulesCore, ReverseDiff, Plots
functionnew_gradient(x)
returnconj((abs(x /2) +1)^(-2))
endfunctionH(a)
return (sign(a) +1) /2endfunctionϕ(x)
returnH(x[1])
end@scalar_ruleϕ(x) new_gradient(x)
function ChainRulesCore.rrule(::typeof(ϕ), x::AbstractArray)
y =ϕ.(x)
functionarray_ϕ_pullback(ȳ)
println("Test.")
ϕ̄ =NoTangent()
x̄ =@thunknew_gradient.(x) * ȳ
return ϕ̄, x̄
endreturn y, array_ϕ_pullback
end
gradplot =let
xs =-5:0.01:5
vals = [ϕ(x) for x in xs]
grads = [ReverseDiff.gradient(ϕ, [x]) for x in xs]
p =plot(xs, vals, label ="ϕ")
plot!(p, xs, getindex.(grads, 1), label ="∇ϕ")
p
end
My own rrules are never called.
Have I made an elementary mistake here, or is this actually a problem with ChainRules?
The text was updated successfully, but these errors were encountered:
Hello everyone,
First off, thank you all for your work on ReverseDiff.
I'm not sure whether this issue belongs here on in the
ChainRules
repo, so forgive me if it's not relevant here.I have tried defining my own pullback using
ChainRules
, which claims to be compatible with ReverseDiff.However, my attempts so far have been unsuccesful.
As a minimal example, take
My own
rrules
are never called.Have I made an elementary mistake here, or is this actually a problem with ChainRules?
The text was updated successfully, but these errors were encountered: