ForwardDiff2.jl icon indicating copy to clipboard operation
ForwardDiff2.jl copied to clipboard

Perturbation Confusion issue

Open MikeInnes opened this issue 5 years ago • 0 comments

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)

MikeInnes avatar Jan 22 '20 10:01 MikeInnes