Closed QiyaoWei closed 2 years ago
That function should just be defined as nograd.
You mean VecJacoperator? But what if the jacobian is part of the training loss?
No, _numargs(f)
Gotcha. Wrapping the function around Zygote.ignore() does take away this error. Out of curiosity, what is the most elegant way to call a function with nograd? Currently I am doing it like this (which works), but not sure if this code looks good
function wrap(f)
Zygote.ignore() do
_numargs(f)
end
end
temp = wrap(f)
#do other stuff
I think you can just add @nograd
on the definition of _numargs
. @oxinabox is there a ChainRulesCore version of Zygote.@nograd
?
Did a PR get made for this?
Turns out, looking closer, the proper fix is https://github.com/JuliaDiff/SparseDiffTools.jl/pull/166
When I write code that looks like
The code here (https://github.com/JuliaDiff/SparseDiffTools.jl/blob/09bc8b1cc1202c93f2a23f8c8497a8c6e1365bdf/src/differentiation/vecjac_products.jl#L8) errs
So I rewrite that line (line 8) in the obvious way
And the error goes away. Not sure why