We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using OrdinaryDiffEq, Distributions, DiffEqUncertainty, ForwardDiff, Zygote, FiniteDiff, DiffEqSensitivity function simplependulum(du,u,p,t) g, L = p du[1] = u[2] du[2] = -(g/L)*sin(u[1]) end u0 = [π/2, 0.0] p = [9.807, 1.0] tspan = (0.0,5.0) prob = ODEProblem(simplependulum, u0, tspan, p) u0_dist = [Uniform(π/2.1, π/1.9), 0.0] p_dist = [9.807, truncated(Normal(1.0,.1), 0.6, 1.4)] g(sol) = sol[1,end] # ∂𝔼/∂u0 test_u0(q) = expectation(g, prob, q, p_dist, Koopman(), Tsit5())[1] @time df1 = ForwardDiff.gradient(test_u0,u0) #Float64[] @time df2 = FiniteDiff.finite_difference_gradient(test_u0,u0) #Float64[] @time df3 = Zygote.gradient(test_u0,u0) #any[] # ∂𝔼/∂p test_p(q) = expectation(g, prob, u0_dist, q, Koopman(), Tsit5())[1] @time df1 = ForwardDiff.gradient(test_p,p) #Float64[] @time df2 = FiniteDiff.finite_difference_gradient(test_p,p) #Float64[] @time df3 = Zygote.gradient(test_p,p) @any[]
However, the following properly returns Float64[] for some reason
Float64[]
# mixed u0/p function test_mixed(q) _u = [u0_dist[1], q[1]] _p = [q[2], p_dist[1]] expectation(g, prob, _u, _p, Koopman(), Tsit5())[1] end x0 = [u0[2], p[1]] @time df1 = ForwardDiff.gradient(test_mixed,x0) #Float64[] @time df2 = FiniteDiff.finite_difference_gradient(test_mixed,x0) #Float64[] @time df3 = Zygote.gradient(test_mixed,x0) #Float64[]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
However, the following properly returns
Float64[]
for some reasonThe text was updated successfully, but these errors were encountered: