Skip to content
New issue

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

Non-exact zero sensitivities for GaussAdjoint #994

Open
ArnoStrouwen opened this issue Jan 29, 2024 · 0 comments
Open

Non-exact zero sensitivities for GaussAdjoint #994

ArnoStrouwen opened this issue Jan 29, 2024 · 0 comments
Labels

Comments

@ArnoStrouwen
Copy link
Member

dynamics = (x, _p, _t) -> x
function loss1(params)
    u0 = zeros(2)
    problem = ODEProblem(dynamics, u0, (0.0, 1.0), params)
    rollout = solve(problem, Tsit5(), u0 = u0, p = params,
        sensealg = InterpolatingAdjoint(autojacvec = ZygoteVJP(allow_nothing=true)))
    sum(Array(rollout)[:, end])
end
function loss2(params)
    u0 = zeros(2)
    problem = ODEProblem(dynamics, u0, (0.0, 1.0), params)
    rollout = solve(problem, Tsit5(), u0 = u0, p = params,
        sensealg = GaussAdjoint(autojacvec = ZygoteVJP()))
    sum(Array(rollout)[:, end])
end
julia> Zygote.gradient(loss1, zeros(123))[1]
123-element Vector{Float64}:
 0.0
 
 0.0

julia> Zygote.gradient(loss2, zeros(123))[1]
123-element Vector{Float64}:
 6.93297084729736e-310
 
 6.9332527492712e-310

One advantage GaussAdjoint has, is that it does not need allow_nothing, but activating it does not resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant