Hi,
I am trying to solve a following problem. I have an objective function that gets some initial parameters (init in the example) and metaparameter(s) (meta in example). The parameters are then updated w.r.t. metaparameters and data (not included in the example for simplicity) and a value of the objective is computed based on the updated parameters (and data). The task is to find optimal metaparameters with JuMP for which I need to compute the gradient.
The problem is that the init is a Float64 array and I am getting the cannot convert ForwardDiff.Dual to Float64 error.
function f(meta, init)
params = copy(init)
for i=2:5
params[i] = meta * params[i-1]
end
return sum(params)
end
s = [1.,2.,3.,4.,5.]
ForwardDiff.gradient(x -> f(x, s), [2])
On slack, I was directed here https://docs.sciml.ai/stable/basics/faq/#I-get-Dual-number-errors-when-I-solve-my-ODE-with-Rosenbrock-or-SDIRK-methods-1 but I could not quite get it to work.