You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is intended behavior, but the output of finite_difference_hessian! is dependent on the values stored in the cache, as illustrated below:
using FiniteDiff
using Random
Random.seed!(1)
# Simple function
f(x) = x[1]^2 + cos(x[2] + 2x[6]) + x[5]*x[4] + x[3]^2
H = zeros(6,6)
x = randn(6)
cache = FiniteDiff.HessianCache(copy(x))
FiniteDiff.finite_difference_hessian!(H,f,x,cache)
H[1,1] # about 2.0 (correct)
# Change the input value drastically
x = randn(6) * 1e6
FiniteDiff.finite_difference_hessian!(H,f,x,cache)
H[1,1] # usually 1.35e7 (far off)
# Set the cache to be equal to the current value
cache.xmm .= x
cache.xmp .= x
cache.xpm .= x
cache.xpp .= x
FiniteDiff.finite_difference_hessian!(H,f,x,cache)
H[1,1] # about 2.0 (correct)
If this is intended behavior, it's probably worth mentioning in the documentation somewhere, and let the user know they should reset the cache variables before calling finite_difference_hessian! for best performance.
The text was updated successfully, but these errors were encountered:
That's not intentional. Yeah it should reset the x caches. It's only doing the element-wise tweaks but never resets it to the base value. Can you PR adding the setup?
I'm not sure if this is intended behavior, but the output of
finite_difference_hessian!
is dependent on the values stored in the cache, as illustrated below:If this is intended behavior, it's probably worth mentioning in the documentation somewhere, and let the user know they should reset the cache variables before calling
finite_difference_hessian!
for best performance.The text was updated successfully, but these errors were encountered: