Skip to content

Commit

Permalink
Update enzyme_closure.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Dec 29, 2023
1 parent 5281083 commit 3abb7ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/enzyme_closure.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SciMLSensitivity, OrdinaryDiffEq
using QuadGK, Enzyme, Zygote, Calculus, LinearAlgebra
using QuadGK, Enzyme, Zygote, ForwardDiff, LinearAlgebra

import Base.zero

Expand Down Expand Up @@ -41,7 +41,7 @@ function paramlength(nn::NN)
end

function get_params(nn::NN)
ret = Float64[]
ret = eltype(layers[1].W)[]
for l in nn.layers
append!(ret, l.W)
append!(ret, l.b)
Expand Down Expand Up @@ -137,7 +137,7 @@ function gintegrate(p)
integral,error = quadgk((t)->(g(sol(t),p,t)) ,tspan...)
return integral
end
refdp = Calculus.gradient(gintegrate,p)
refdp = ForwardDiff.gradient(gintegrate,p)

du1,dp1 = adjoint_sensitivities(sol,Tsit5(),g=g,sensealg=BacksolveAdjoint(autodiff=true,autojacvec=EnzymeVJP()),abstol=1e-10,reltol=1e-10)
@test isapprox(dp1',refdp,atol=1e-3)
Expand Down

0 comments on commit 3abb7ed

Please sign in to comment.