Adjoint not defined for 3D output of ODESolution?

I am trying to use Flux.batch for my DL model in Julia. The model is nothing but an ODE system. I want to updated the parameter on ODE by training.
Without batch, the output of ODE is 2D array, which works well with training. But by using Flux.batch, ODE output becomes 3D array, and here comes the error:

ERROR: LoadError: adjoint not defined for ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Array{Float64,1},ODEFunction{true,var"#V2O3_system!#371"{V2O3,var"#inputFunction#370"{Array{Float64,3},Tuple{Float64,Float64}},Array{Float64,2}},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,var"#V2O3_system!#371"{V2O3,var"#inputFunction#370"{Array{Float64,3},Tuple{Float64,Float64}},Array{Float64,2}},UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats}. Consider using permutedims
for higher-dimensional arrays.

I’ve already checked out permutedims as in error message,but no idea how it helps…
I would be grateful of any insights into the problem origin and possible solution. Thanks

The output of a differential equation isn’t an array, it’s an ODESolution. If you want an array, do Array(sol). There’s a chance that might just fix your issue? Otherwise I’d have to see a bit more. You may want to use the following tutorial for guidance as it features mini-batching:

https://diffeqflux.sciml.ai/dev/examples/mnist_neural_ode/

1 Like