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

Fix hessian calculation with FiniteDiff #319

Merged
merged 1 commit into from
Jul 9, 2022
Merged

Conversation

Vaibhavdixit02
Copy link
Member

This was the case due to JuliaDiff/FiniteDiff.jl#127

@codecov
Copy link

codecov bot commented Jul 9, 2022

Codecov Report

Merging #319 (0d0ef0e) into master (edbae8c) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #319   +/-   ##
=======================================
  Coverage   79.37%   79.37%           
=======================================
  Files           9        9           
  Lines         257      257           
=======================================
  Hits          204      204           
  Misses         53       53           
Impacted Files Coverage Δ
src/function/finitediff.jl 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@@ -56,7 +56,7 @@ function instantiate_function(f, x, adtype::AutoFiniteDiff, p, num_cons=0)
end

if f.hess === nothing
hess = (res, θ, args...) -> FiniteDiff.finite_difference_hessian!(res, x -> _f(x, args...), θ, FiniteDiff.HessianCache(x, adtype.fdhtype))
hess = (res, θ, args...) -> FiniteDiff.finite_difference_hessian!(res, x -> _f(x, args...), θ, FiniteDiff.HessianCache(θ, adtype.fdhtype))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also cache the caches.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that instead of creating a new one for every call reset it and use here and have it defined once only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ForwardDiff should do that too. That why the precaching interface exists. It doesn't matter too much for the ODE cases since those are so much more expensive than the allocations that they are hardly noticed, but it's a detail we should fix. We can do that in a follow up PR

@ChrisRackauckas ChrisRackauckas merged commit bccfa4f into master Jul 9, 2022
@ChrisRackauckas ChrisRackauckas deleted the finitehess branch July 9, 2022 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants