I am wondering if there are several typos in introduction example to custom adjoints,
https://fluxml.ai/Zygote.jl/dev/adjoints/
In other words
pullback(sin, x)
behaves the same asdsin(x) = sin(x), ȳ -> (ȳ * cos(x),)
Is the dsin(x) = sin(x) correct? Does this mean that pullback(sin,x) returns a tuple containing 1) an new aliased function for sin, 2) a function that returns whatever its argument is times cos(x)?
Then the next example says
gradient
takes a function l=f(x) and … feeds this in to the pullback. In the case ofsin
,
julia> function gradsin(x)
_, back = dsin(x)
back(1)
end
Multiple strange things here (to me). 1) pullback is not called anywhere,
2) dsin(x) = sin(x), so back is equal to sin(0.5), and is not a function (so back(1) should give an error)
Are there any more clear documentation?