-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Description
Hello,
Recently i came across with a problem in which already had a hessian cache, (HessianConfig
+ DiffResults.HessianResult
), but it seems there aren't any methods for calculating for using HessianConfig
(and HessianResult
) when calculating gradients (of the same function with the same number and type of arguments).
I did this dirty hack to allow calculating gradients with HessianConfig
+ HessianResult
:
hresult,hconfig = cache
h_jconfig = hconfig.jacobian_config
seeds = h_jconfig.seeds
duals = h_jconfig.duals[1]
gconfig = ForwardDiff.GradientConfig{Nothing,eltype(aux),length(seeds),typeof(duals)}(seeds,duals)
gresult = ForwardDiff.MutableDiffResult(result.value,(result.derivs[1],))
It works for me, but it could be generalized (by passing the adequate function argument, for example)
It would be much easier to just do ForwardDiff.gradient!(hresult,f,x,hconfig)
instead.
Metadata
Metadata
Assignees
Labels
No labels