Hi all,
I’ve recently started using Julia for machine learning purposes. I’ve just started playing around with neural networks using Flux and DiffEqFlux. I am trying to run some of the example code from the DiffEqFlux but I’m unable to, always getting the same error.
Here is some code, adapted from the example code on the site, which helped me pinpoint where the error is coming from:
using Flux, DiffEqFlux, DifferentialEquations
function lotka_volterra(du,u,p,t)
x, y = u
α, β, δ, γ = p
du[1] = dx = α*x - β*x*y
du[2] = dy = -δ*y + γ*x*y
end
parameters = [2.2; 1.0; 2.0; 0.4] # Initial Parameter Vector
u_0 = [1.0, 1.0]
tspan = (0.0, 10.0)
prob = ODEProblem(lotka_volterra, u0, tspan, parameters);
function predict_rd(u0)
prob = ODEProblem(lotka_volterra, u0, tspan, parameters);
solve(prob, Tsit5(), saveat=0.1)[1, :]
end
function loss_rd(u0)
sum((predict_rd(u0) .- 1).^2)
end
predict_rd(u_0)
gs = gradient(() -> loss_rd(u_0), params(parameters))
When the last line is run, where the gradient is to be calculated, I get the following error:
LoadError: ArgumentError: tuple must be non-empty
in expression starting at C:\Users\chris\neural_nets_tutorials\gradient_test.jl:33
first(::Tuple{}) at tuple.jl:95
_unapply(::Nothing, ::Tuple{}) at lib.jl:163
_unapply(::Tuple{Nothing}, ::Tuple{}) at lib.jl:167
_unapply(::Tuple{Tuple{Nothing}}, ::Tuple{}) at lib.jl:167
_unapply(::Tuple{NTuple{6,Nothing},Tuple{Nothing}}, ::Tuple{Nothing,Nothing,Nothing,Array{Float64,1},Array{Float64,1},Nothing}) at lib.jl:168
unapply(::Tuple{NTuple{6,Nothing},Tuple{Nothing}}, ::Tuple{Nothing,Nothing,Nothing,Array{Float64,1},Array{Float64,1},Nothing}) at lib.jl:177
(::Zygote.var"#188#189"{Zygote.var"#kw_zpullback#40"{DiffEqSensitivity.var"#adjoint_sensitivity_backpass#179"{Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Tsit5,InterpolatingAdjoint{0,true,Val{:central},Bool,Bool},Array{Float64,1},Array{Float64,1},Tuple{},NamedTuple{(),Tuple{}},Colon}},Tuple{NTuple{6,Nothing},Tuple{Nothing}}})(::Array{Float64,2}) at lib.jl:195
(::Zygote.var"#1741#back#190"{Zygote.var"#188#189"{Zygote.var"#kw_zpullback#40"{DiffEqSensitivity.var"#adjoint_sensitivity_backpass#179"{Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Tsit5,InterpolatingAdjoint{0,true,Val{:central},Bool,Bool},Array{Float64,1},Array{Float64,1},Tuple{},NamedTuple{(),Tuple{}},Colon}},Tuple{NTuple{6,Nothing},Tuple{Nothing}}}})(::Array{Float64,2}) at adjoint.jl:59
#solve#59 at solve.jl:70 [inlined]
(::typeof(∂(#solve#59)))(::Array{Float64,2}) at interface2.jl:0
(::Zygote.var"#188#189"{typeof(∂(#solve#59)),Tuple{NTuple{6,Nothing},Tuple{Nothing}}})(::Array{Float64,2}) at lib.jl:194
(::Zygote.var"#1741#back#190"{Zygote.var"#188#189"{typeof(∂(#solve#59)),Tuple{NTuple{6,Nothing},Tuple{Nothing}}}})(::Array{Float64,2}) at adjoint.jl:59
solve at solve.jl:68 [inlined]
(::typeof(∂(solve##kw)))(::Array{Float64,2}) at interface2.jl:0
predict_rd at gradient_test.jl:21 [inlined]
(::typeof(∂(predict_rd)))(::Array{Float64,1}) at interface2.jl:0
loss_rd at gradient_test.jl:27 [inlined]
(::typeof(∂(loss_rd)))(::Float64) at interface2.jl:0
#119 at gradient_test.jl:33 [inlined]
(::typeof(∂(#119)))(::Float64) at interface2.jl:0
(::Zygote.var"#69#70"{Params,Zygote.Context,typeof(∂(#119))})(::Float64) at interface.jl:255
gradient(::Function, ::Params) at interface.jl:59
top-level scope at gradient_test.jl:33
include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088
I’ve tried to update DiffEqSensitivity to version 6.50.1, per this post’s suggestion (DiffEqFlux Example codes not working), but this gives the following error:
ERROR: Unsatisfiable requirements detected for package CuArrays [3a865a2d]:
I’ve cut the above output short as it is very long.
These are my package versions:
[aae7a2af] DiffEqFlux v1.39.0
[41bf760c] DiffEqSensitivity v6.49.1
[0c46a032] DifferentialEquations v6.18.0
[587475ba] Flux v0.12.1
I’d be grateful for any help. Just trying to get the example codes to run so I can finally start applying these methods