Skip to content

Commit e69ac19

Browse files
Update example.md
1 parent c4b193b commit e69ac19

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

docs/src/example.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using Zygote
4646
using SciMLSensitivity
4747
4848
# 5 subparams[i].p, 50 elements in coeffs
49-
Zygote.gradient(0.1ones(55)) do tunables
49+
function simulate_with_tunables(tunables)
5050
subpars = [SubproblemParameters(tunables[i], subpar.q, subpar.r) for (i, subpar) in enumerate(p.subparams)]
5151
coeffs = reshape(tunables[6:end], size(p.coeffs))
5252
newp = Parameters(subpars, coeffs)
@@ -113,12 +113,7 @@ end
113113
Now, we should be able to differentiate through the ODE solve.
114114

115115
```@example basic_tutorial
116-
Zygote.gradient(0.1ones(length(SS.canonicalize(SS.Tunable(), p)[1]))) do tunables
117-
newp = SS.replace(SS.Tunable(), p, tunables)
118-
newprob = remake(prob; p = newp)
119-
sol = solve(newprob, Tsit5())
120-
return sum(sol.u[end])
121-
end
116+
Zygote.gradient(simulate_with_tunables, 0.1ones(length(SS.canonicalize(SS.Tunable(), p)[1])))
122117
```
123118

124119
We can also implement a `Constants` portion to store the rest of the values:

0 commit comments

Comments
 (0)