I need to work with individual Wiener increments from an SDE solution in my loss function. Whenever I try to get these values from
sol.W.W command, the
ERROR: type Nothing has no field W pops up when computing the gradients. Can it be a bug in DiffEqSensitivity package?
using DifferentialEquations, Flux, DiffEqFlux using DiffEqSensitivity function dt!(du, u, p, t) x, y = u α, β, δ, γ = p du = dx = α*x - β*x*y du = dy = -δ*y + γ*x*y end function dW!(du, u, p, t) du = 0.1u du = 0.1u end u0 = [1.0,1.0] tspan = (0.0, 10.0) p = [2.2, 1.0, 2.0, 0.4] W = WienerProcess(0.0,0.0,0.0) prob_sde = SDEProblem(dt!, dW!, u0, tspan,p,noise=W) function some_loss(p) #some loss function sol=solve(prob_sde, EM(), saveat = 0.1,sensealg = ForwardDiffSensitivity(), dt=0.001) Wsum=sum(sol.W.W) #problematic part println("Wsum=",Wsum) sum(abs2, x-1 for x in Array(sol)) end ps = Flux.params(p) @time gs = gradient(ps) do some_loss(p) end #ERROR: type Nothing has no field W