Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Mar 4, 2024
1 parent c0e15c5 commit 6aff9a0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/adjoint_shapes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ solve(
ODEAdjointProblem(fwd_sol, sensealg, Tsit5(), [1.0],
(out, x, p, t, i) -> (out .= 1)),
Tsit5())

# https://github.com/SciML/SciMLSensitivity.jl/issues/581

p = rand(1)

function dudt(u, p, t)
u .* p
end

function loss(p)
prob = ODEProblem(dudt, [3.0], (0.0, 1.0), p)
sol = solve(prob, Tsit5(), dt=0.01, sensealg=ReverseDiffAdjoint())
sum(abs2, Array(sol))
end
Zygote.gradient(loss, p)

0 comments on commit 6aff9a0

Please sign in to comment.