Skip to content

Commit

Permalink
build based on 2ac75a0
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Jul 30, 2023
1 parent 7a272ac commit 7067e3b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions previews/PR64/api/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion previews/PR64/examples/0_intro/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
return c
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">conditions (generic function with 1 method)</code></pre><p>Finally, we construct a wrapper <code>implicit</code> around the previous objects. By default, <code>forward</code> is assumed to return a single output and <code>conditions</code> is assumed to accept 2 arguments.</p><pre><code class="language-julia hljs">implicit = ImplicitFunction(forward, conditions)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">ImplicitFunction(forward, conditions, IterativeLinearSolver())</code></pre><p>What does this wrapper do? When we call it as a function, it just falls back on <code>first ∘ implicit.forward</code>, so unsurprisingly we get the first output <span>$y(x)$</span>.</p><pre><code class="language-julia hljs">implicit(x) ≈ sqrt.(x)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">true</code></pre><p>And when we try to compute its Jacobian, the <a href="https://en.wikipedia.org/wiki/Implicit_function_theorem">implicit function theorem</a> is applied in the background to circumvent the lack of differentiablility of the forward mapping.</p><h2 id="Forward-and-reverse-mode-autodiff"><a class="docs-heading-anchor" href="#Forward-and-reverse-mode-autodiff">Forward and reverse mode autodiff</a><a id="Forward-and-reverse-mode-autodiff-1"></a><a class="docs-heading-anchor-permalink" href="#Forward-and-reverse-mode-autodiff" title="Permalink"></a></h2><p>Now ForwardDiff.jl works seamlessly.</p><pre><code class="language-julia hljs">ForwardDiff.jacobian(implicit, x) ≈ J</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">true</code></pre><p>And so does Zygote.jl. Hurray!</p><pre><code class="language-julia hljs">Zygote.jacobian(implicit, x)[1] ≈ J</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">true</code></pre><h2 id="Second-derivative"><a class="docs-heading-anchor" href="#Second-derivative">Second derivative</a><a id="Second-derivative-1"></a><a class="docs-heading-anchor-permalink" href="#Second-derivative" title="Permalink"></a></h2><p>We can even go higher-order by mixing the two packages (forward-over-reverse mode). The only technical requirement is to switch the linear solver to something that can handle dual numbers:</p><pre><code class="language-julia hljs">implicit_higher_order = ImplicitFunction(forward, conditions, DirectLinearSolver())</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">ImplicitFunction(forward, conditions, DirectLinearSolver())</code></pre><p>Then the Jacobian itself is differentiable.</p><pre><code class="language-julia hljs">h = rand(2)
J_Z(t) = Zygote.jacobian(implicit_higher_order, x .+ t .* h)[1]
ForwardDiff.derivative(J_Z, 0) ≈ Diagonal((-0.25 .* h) ./ (x .^ 1.5))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">true</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../">« Home</a><a class="docs-footer-nextpage" href="../1_basic/">Basic use cases »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 11:57">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
ForwardDiff.derivative(J_Z, 0) ≈ Diagonal((-0.25 .* h) ./ (x .^ 1.5))</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">true</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../">« Home</a><a class="docs-footer-nextpage" href="../1_basic/">Basic use cases »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 12:47">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion previews/PR64/examples/1_basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@
Zygote.jacobian(_x -&gt; forward_fixedpoint(_x; iterations=10), x)[1]
catch e
e
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">ErrorException(&quot;Mutating arrays is not supported -- called copyto!(Vector{Float64}, ...)\nThis error occurs when you ask Zygote to differentiate operations that change\nthe elements of arrays in place (e.g. setting values with x .= ...)\n\nPossible fixes:\n- avoid mutating operations (preferred)\n- or read the documentation and solutions for this error\n https://fluxml.ai/Zygote.jl/latest/limitations\n&quot;)</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../0_intro/">« Introduction</a><a class="docs-footer-nextpage" href="../2_advanced/">Advanced use cases »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 11:57">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">ErrorException(&quot;Mutating arrays is not supported -- called copyto!(Vector{Float64}, ...)\nThis error occurs when you ask Zygote to differentiate operations that change\nthe elements of arrays in place (e.g. setting values with x .= ...)\n\nPossible fixes:\n- avoid mutating operations (preferred)\n- or read the documentation and solutions for this error\n https://fluxml.ai/Zygote.jl/latest/limitations\n&quot;)</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../0_intro/">« Introduction</a><a class="docs-footer-nextpage" href="../2_advanced/">Advanced use cases »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 12:47">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion previews/PR64/examples/2_advanced/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
Zygote.jacobian(forward_cstr_optim, x)[1]
catch e
e
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Zygote.CompileError(Tuple{typeof(Optim.optimize), NLSolversBase.OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Optim.Fminbox{Optim.GradientDescent{LineSearches.InitialPrevious{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Nothing, Optim.var&quot;#13#15&quot;}, Float64, Optim.var&quot;#49#51&quot;}, Optim.Options{Float64, Nothing}}, ErrorException(&quot;try/catch is not supported.\nRefer to the Zygote documentation for fixes.\nhttps://fluxml.ai/Zygote.jl/latest/limitations\n&quot;))</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../1_basic/">« Basic use cases</a><a class="docs-footer-nextpage" href="../3_tricks/">Tricks »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 11:57">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
end</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Zygote.CompileError(Tuple{typeof(Optim.optimize), NLSolversBase.OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Optim.Fminbox{Optim.GradientDescent{LineSearches.InitialPrevious{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Nothing, Optim.var&quot;#13#15&quot;}, Float64, Optim.var&quot;#49#51&quot;}, Optim.Options{Float64, Nothing}}, ErrorException(&quot;try/catch is not supported.\nRefer to the Zygote documentation for fixes.\nhttps://fluxml.ai/Zygote.jl/latest/limitations\n&quot;))</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../1_basic/">« Basic use cases</a><a class="docs-footer-nextpage" href="../3_tricks/">Tricks »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 12:47">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion previews/PR64/examples/3_tricks/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@

implicit_cointoss(x)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">2-element Vector{Float64}:
2.0
2.0</code></pre><p>Or if you also need the byproduct, you can do</p><pre><code class="language-julia hljs">implicit_cointoss(x, ReturnByproduct())</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">([0.5, 0.5], false)</code></pre><p>But whatever you choose, the byproduct is taken into account during differentiation!</p><pre><code class="language-julia hljs">Zygote.withjacobian(implicit_cointoss, x)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">(val = [0.5, 0.5], grad = ([0.5 0.0; 0.0 0.5],))</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../2_advanced/">« Advanced use cases</a><a class="docs-footer-nextpage" href="../../api/">API reference »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 11:57">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2.0</code></pre><p>Or if you also need the byproduct, you can do</p><pre><code class="language-julia hljs">implicit_cointoss(x, ReturnByproduct())</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">([0.5, 0.5], false)</code></pre><p>But whatever you choose, the byproduct is taken into account during differentiation!</p><pre><code class="language-julia hljs">Zygote.withjacobian(implicit_cointoss, x)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">(val = [0.5, 0.5], grad = ([0.5 0.0; 0.0 0.5],))</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../2_advanced/">« Advanced use cases</a><a class="docs-footer-nextpage" href="../../api/">API reference »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></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> version 0.27.25 on <span class="colophon-date" title="Sunday 30 July 2023 12:47">Sunday 30 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 7067e3b

Please sign in to comment.