ForwardDiff2.jl
ForwardDiff2.jl copied to clipboard
Perturbation Confusion issue
julia> D(f, x) = ForwardDiff2.D(f)(x)*1
D (generic function with 1 method)
julia> function test()
x = 2
D(1) do y
x = y*x
end
D(1) do y
x = y*x
end
end
test (generic function with 1 method)
julia> test()
4
julia> D(f, x) = Zygote.gradient(f, x)[1]
D (generic function with 1 method)
julia> test()
2
julia> D(f, x) = Tracker.gradient(f, x, nest = true)[1]
D (generic function with 1 method)
julia> test()
2.0 (tracked)