Open Vilin97 opened 1 year ago
Basically this needs to be done by writing ChainRules that tell Zygote how to differentiate integrals without differentiating through the (mutating) code.
Fortunately, this has already been done — if you use https://github.com/SciML/Integrals.jl, then it provides a wrapper around QuadGK that provides the appropriate ChainRules.
In the longer run it might be worth adding chain rules to QuadGK directly.
Autodiff in Integrals.jl was recently fixed in this PR https://github.com/SciML/Integrals.jl/pull/175 and it should be available in its next release.
Thank you for a great package! I would like to use Zygote on
quadgk
but below is a self-contained example, where it does not work becausequadgk
callssetindex!
. Can I do anything to work around this? I coded up a small example of differentiatingquadgk
of a constant function and it did work so it seems that there is hope for Zygote and QuadGK to play together nicely.