Closed duochanatharvard closed 2 years ago
It seems the question was posted on discourse as well (https://discourse.julialang.org/t/typeerror-in-julia-turing-when-sampling-for-a-forced-differential-equation/). Chris explained the issue there, u0
is not promoted to the correct type. It seems the question was answered on discourse and a fix was provided.
Please feel free to reopen if the problem persists after promoting u0
.
Hi
I am new to Julia and Turing and am trying to fit a forced 0-D box ODE to data, but I get type error when doing sampling.
The tutorial (https://turing.ml/dev/tutorials/10-bayesian-differential-equations/) gives an example for unforced LV model. Following this page (https://stackoverflow.com/questions/49428939/solve-system-of-odes-with-read-in-external-forcing), I added an interpolation handle of the forcing as a parameter of the ODE, and the ODE solver runs without problems.
When I combine the forced ODE with Turing, however, I get a type error during HMC's gradient calculation, quoting ”TypeError: in typeassert, expected Float64, got a value of type ForwardDiff.Dual{Nothing, Float64, 3}”.
Below are my codes that should reproduce the error I got.
I appreciate any help, Thanks.
Below are my codes: