Open
Description
See the following code.
Pseudocode + explanations:
f = x1 * x2
grad_f = (x2, x1)
fg = sum(grad_f) = x2+x1
grad_fg = [1, 1]
Actual code:
using Tracker
x = param([1, 2]) # Tracked 3-element Vector{Float64}
f(x) = prod(x)
g(x) = gradient(f, x, nest=true)
fg(x) = sum(g(x)[1])
gg = gradient(fg, x)
The value of gg
is [-2.0, -0.5]
instead of [1, 1]
Metadata
Metadata
Assignees
Labels
No labels