Here is the rest of informations:
julia> show(err)
1-element ExceptionStack:
LoadError: Adjoint sensitivity analysis functionality requires being able to solve
a differential equation defined by the parameter struct `p`. Thus while
DifferentialEquations.jl can support any parameter struct type, usage
with adjoint sensitivity analysis requires that `p` could be a valid
type for being the initial condition `u0` of an array. This means that
many simple types, such as `Tuple`s and `NamedTuple`s, will work as
parameters in normal contexts but will fail during adjoint differentiation.
To work around this issue for complicated cases like nested structs, look
into defining `p` using `AbstractArray` libraries such as RecursiveArrayTools.jl
or ComponentArrays.jl so that `p` is an `AbstractArray` with a concrete element type.
Stacktrace:
[1] _concrete_solve_adjoint(::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float32}, Vector{Float32}, ChemicalReactionNN, Float32}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}, ChemicalReactionNN, Float32}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}, Vector{Float32}, ChemicalReactionNN, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}, ChemicalReactionNN, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float32}, Float32, 1}}}}, false}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, ::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, ::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}, ::Vector{Float32}, ::ChemicalReactionNN, ::SciMLBase.ChainRulesOriginator; save_start::Bool, save_end::Bool, saveat::StepRangeLen{Float32, Float64, Float64, Int64}, save_idxs::Nothing, initializealg_default::SciMLBase.OverrideInit{Float64, Float64, Nothing}, kwargs::@Kwargs{})
@ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/KLsRs/src/concrete_solve.jl:381
[2] _solve_adjoint(prob::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(crnn_ode!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, sensealg::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}, u0::Vector{Float32}, p::ChemicalReactionNN, originator::SciMLBase.ChainRulesOriginator, args::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}; merge_callbacks::Bool, kwargs::@Kwargs{saveat::StepRangeLen{Float32, Float64, Float64, Int64}})
@ DiffEqBase ~/.julia/packages/DiffEqBase/5hvMq/src/solve.jl:1685
[3] rrule(::typeof(DiffEqBase.solve_up), prob::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(crnn_ode!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, sensealg::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}, u0::Vector{Float32}, p::ChemicalReactionNN, args::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}; kwargs::@Kwargs{saveat::StepRangeLen{Float32, Float64, Float64, Int64}})
@ DiffEqBaseChainRulesCoreExt ~/.julia/packages/DiffEqBase/5hvMq/ext/DiffEqBaseChainRulesCoreExt.jl:26
[4] kwcall(::@NamedTuple{saveat::StepRangeLen{Float32, Float64, Float64, Int64}}, ::typeof(ChainRulesCore.rrule), ::Zygote.ZygoteRuleConfig{Zygote.Context{false}}, ::Function, ::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(crnn_ode!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, ::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}, ::Vector{Float32}, ::ChemicalReactionNN, ::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False})
@ ChainRulesCore ~/.julia/packages/ChainRulesCore/U6wNx/src/rules.jl:144
[5] chain_rrule_kw
@ ~/.julia/packages/Zygote/wfLOG/src/compiler/chainrules.jl:246 [inlined]
[6] macro expansion
@ ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0 [inlined]
[7] _pullback(::Zygote.Context{false}, ::typeof(Core.kwcall), ::@NamedTuple{saveat::StepRangeLen{Float32, Float64, Float64, Int64}}, ::typeof(DiffEqBase.solve_up), ::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(crnn_ode!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, ::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}, ::Vector{Float32}, ::ChemicalReactionNN, ::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False})
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:81
[8] _apply(::Function, ::Vararg{Any})
@ Core ./boot.jl:838
[9] adjoint
@ ~/.julia/packages/Zygote/wfLOG/src/lib/lib.jl:199 [inlined]
[10] _pullback
@ ~/.julia/packages/ZygoteRules/CkVIK/src/adjoint.jl:67 [inlined]
[11] #solve#43
@ ~/.julia/packages/DiffEqBase/5hvMq/src/solve.jl:1089 [inlined]
[12] _pullback(::Zygote.Context{false}, ::DiffEqBase.var"##solve#43", ::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}, ::Nothing, ::Nothing, ::Val{true}, ::@Kwargs{saveat::StepRangeLen{Float32, Float64, Float64, Int64}}, ::typeof(solve), ::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(crnn_ode!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, ::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False})
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[13] _apply(::Function, ::Vararg{Any})
@ Core ./boot.jl:838
[14] adjoint
@ ~/.julia/packages/Zygote/wfLOG/src/lib/lib.jl:199 [inlined]
[15] _pullback
@ ~/.julia/packages/ZygoteRules/CkVIK/src/adjoint.jl:67 [inlined]
[16] solve
@ ~/.julia/packages/DiffEqBase/5hvMq/src/solve.jl:1079 [inlined]
[17] _pullback(::Zygote.Context{false}, ::typeof(Core.kwcall), ::@NamedTuple{saveat::StepRangeLen{Float32, Float64, Float64, Int64}, sensealg::InterpolatingAdjoint{0, true, Val{:central}, ReverseDiffVJP{true}}}, ::typeof(solve), ::ODEProblem{Vector{Float32}, Tuple{Float32, Float32}, true, ChemicalReactionNN, ODEFunction{true, SciMLBase.AutoSpecialize, typeof(crnn_ode!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, @Kwargs{}, SciMLBase.StandardODEProblem}, ::Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False})
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[18] simulate_differentiable
@ ~/CRNN/CRNN_2_reac_consec_v2.jl:68 [inlined]
[19] _pullback(::Zygote.Context{false}, ::typeof(simulate_differentiable), ::ChemicalReactionNN, ::Vector{Float32}, ::Tuple{Float32, Float32}, ::StepRangeLen{Float32, Float64, Float64, Int64})
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[20] #35
@ ~/CRNN/CRNN_2_reac_consec_v2.jl:98 [inlined]
[21] _pullback(ctx::Zygote.Context{false}, f::var"#35#36"{Vector{Float32}, Matrix{Float32}, StepRangeLen{Float32, Float64, Float64, Int64}, Tuple{Float32, Float32}}, args::ChemicalReactionNN)
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface2.jl:0
[22] pullback(f::Function, cx::Zygote.Context{false}, args::ChemicalReactionNN)
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface.jl:96
[23] pullback
@ ~/.julia/packages/Zygote/wfLOG/src/compiler/interface.jl:94 [inlined]
[24] withgradient(f::Function, args::ChemicalReactionNN)
@ Zygote ~/.julia/packages/Zygote/wfLOG/src/compiler/interface.jl:211
[25] #withgradient#5
@ ~/.julia/packages/Flux/3711C/src/gradient.jl:182 [inlined]
[26] withgradient
@ ~/.julia/packages/Flux/3711C/src/gradient.jl:169 [inlined]
[27] train_crnn(crnn::ChemicalReactionNN, c_init::Vector{Float32}, target::Matrix{Float32}, epochs::Int64, lr::Float32)
@ Main ~/CRNN/CRNN_2_reac_consec_v2.jl:97
[28] train_crnn
@ ~/CRNN/CRNN_2_reac_consec_v2.jl:86 [inlined]
[29] main()
@ Main ~/CRNN/CRNN_2_reac_consec_v2.jl:157
[30] top-level scope
@ ~/CRNN/CRNN_2_reac_consec_v2.jl:189
[31] eval
@ ./boot.jl:385 [inlined]
[32] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
@ Base ./loading.jl:2146
[33] include_string(m::Module, txt::String, fname::String)
@ Base ./loading.jl:2156
[34] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
@ Base ./essentials.jl:892
[35] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base ./essentials.jl:889
[36] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/eval.jl:271
[37] (::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/eval.jl:181
[38] withpath(f::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/repl.jl:276
[39] (::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/eval.jl:179
[40] hideprompt(f::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/repl.jl:38
[41] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/eval.jl:150
[42] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging ./logging.jl:515
[43] with_logger
@ ./logging.jl:627 [inlined]
[44] (::VSCodeServer.var"#66#71"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/eval.jl:263
[45] #invokelatest#2
@ ./essentials.jl:892 [inlined]
[46] invokelatest(::Any)
@ Base ./essentials.jl:889
[47] (::VSCodeServer.var"#64#65")()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.140.2/scripts/packages/VSCodeServer/src/eval.jl:34
in expression starting at /home/aquarelle/CRNN/CRNN_2_reac_consec_v2.jl:189