-end</code></pre><p>However, sometimes such re-binding confuses Zygote, especially if the type of the value changes. Especially if the variable is "boxed", as will happen if you re-bind from within a closure (such as the function created by a <code>do</code> block).</p><h2 id="Second-derivatives-1"><a class="docs-heading-anchor" href="#Second-derivatives-1">Second derivatives</a><a class="docs-heading-anchor-permalink" href="#Second-derivatives-1" title="Permalink"></a></h2><p>In principle Zygote supports taking derivatives of derivatives. There are, however, a few problems:</p><ul><li>Quite a few of its rules are not written in a way that is itself differentiable. For instance they may work by making an array then writing into it, which is mutation of the sort forbidden above. </li><li>The complexity of the code grows rapidly, as Zygote differentiates its own un-optimised output.</li><li>Reverse mode over reverse mode is seldom the best algorithm.</li></ul><p>The issue tracker has a label for <a href="https://github.com/FluxML/Zygote.jl/issues?q=is%3Aissue+is%3Aopen+label%3A%22second+order%22">second order</a>, which will outline where the bodies are buried.</p><p>Often using a different AD system over Zygote is a better solution. This is what <a href="../utils/#Zygote.hessian"><code>hessian</code></a> does, using ForwardDiff over Zygote, but other combinations are possible. (Note that rules defined here mean that Zygote over ForwardDiff is translated to ForwardDiff over ForwardDiff.)</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../adjoints/">Custom Adjoints »</a></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Monday 30 December 2024 10:01">Monday 30 December 2024</span>. Using Julia version 1.11.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
0 commit comments