尝试调用隐式欧拉求解 ODE 时,我收到以下错误:
MethodError: no method matching OrdinaryDiffEq.NLNewtonConstantCache(::Float32, ::Array{Float64,2}, ::LinearAlgebra.LU{Float64,Array{Float64,2}}, ::Bool, ::Bool, ::Bool, ::Float32, ::DiffEqBase.UDerivativeWrapper{ODEFunction{false,DiffEqFlux.var"#dudt_#50"{NeuralODE{Chain{Tuple{Dense{typeof(tanh),Array{Float32,2},Array{Float32,1}},Dense{typeof(identity),Array{Float32,2},Array{Float32,1}}}},Array{Float32,1},Flux.var"#12#14"{Chain{Tuple{Dense{typeof(tanh),Array{Float32,2},Array{Float32,1}},Dense{typeof(identity),Array{Float32,2},Array{Float32,1}}}}},Tuple{Float32,Float32},ImplicitEuler{0,false,DefaultLinSolve,NLNewton{Rational{Int64},Rational{Int64},Rational{Int64}},DataType},Tuple{},Base.Iterators.Pairs{Symbol,Any,NTuple{4,Symbol},NamedTuple{(:dt, :saveat, :reltol, :abstol),Tuple{Float64,StepRangeLen{Float32,Float64,Float64},Float64,Float64}}}}},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float32,Array{Float32,1}}, ::Float64, ::Float32, ::Float32)
Closest candidates are:
OrdinaryDiffEq.NLNewtonConstantCache(::tType, ::J, ::W, ::Bool, ::Bool, ::Bool, ::tType, ::ufType, !Matched::tType, ::tType, ::tType) where {tType, J, W, ufType} at /Users/sdoneva/.julia/packages/OrdinaryDiffEq/nV9bA/src/nlsolve/type.jl:62
这就是我调用求解器的方式:
using Flux, DiffEqFlux, DifferentialEquations, Plots
u0 = [1.0,1.0]
solver = ImplicitEuler(autodiff = false)
tspan_train = (0.0f0,4.00f0)
train_size = 32
t_train = range(tspan_train[1],tspan_train[2],length = train_size)
function create_neural_ode(solver, tspan, t_saveat)
dudt = Chain(
Dense(2,50,tanh),
Dense(50,2))
ps = Flux.params(dudt)
n_ode = NeuralODE(dudt, tspan, solver, dt=1/2^4, saveat = t_saveat, reltol=1e-7, abstol=1e-9)
n_ode
end
n_ode = create_neural_ode(solver, tspan_train, t_train)
plot(n_ode(u0))
调用 ImplicitEuler 的正确方法是什么?