SciML / DataDrivenDiffEq.jl

Data driven modeling and automated discovery of dynamical systems for the SciML Scientific Machine Learning organization
https://docs.sciml.ai/DataDrivenDiffEq/stable/
MIT License
405 stars 57 forks source link

hudson_bay.jl throws error on my machine #250

Open HenriLaurie opened 3 years ago

HenriLaurie commented 3 years ago

I am trying to run the code in LotkaVolterra of universal_differential_equations.jl. Am succeeding with them except for hudson_bay.jl. Here is the first few lines of the error message:

┌ Warning: Interrupted. Larger maxiters is needed.
└ @ SciMLBase ~/.julia/packages/SciMLBase/kCcpg/src/integrator_interface.jl:331
ERROR: LoadError: DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 9 and 21")
Stacktrace:
  [1] _bcs1
    @ ./broadcast.jl:501 [inlined]
  [2] _bcs (repeats 2 times)
    @ ./broadcast.jl:495 [inlined]

and the last few lines

┌ Warning: Interrupted. Larger maxiters is needed.
└ @ SciMLBase ~/.julia/packages/SciMLBase/kCcpg/src/integrator_interface.jl:331
ERROR: LoadError: DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 9 and 21")
Stacktrace:
  [1] _bcs1
    @ ./broadcast.jl:501 [inlined]
  [2] _bcs (repeats 2 times)
    @ ./broadcast.jl:495 [inlined]

Called by include() in the REPL of Code-OSS, with the LotkaVolterra directory instantiated (so I think using the .toml files as downloaded).

AlCap23 commented 3 years ago

Seems like it's related to the training loop of the ude. Have you tried running it from the terminal directly? Otherwise, the initial parameters of the network might have an influence, which should be handled by the random seed. If you haven't changed anything else.

HenriLaurie commented 3 years ago

Hm. Running from REPL. Getting precompilation warnings I didn't see in Code-OSS, about ModelingToolkit and Enzyme (under DiffEqFlux). But such warnings shouldn't matter, should they?

Anyway, the error remains, same message. I notice I pasted the same extract twice. Here is what I meant to include, it confirms that it is during the sciml_train() call that things go wrong.

 [46] sciml_train(::typeof(loss_fit), ::Vector{Float64}, ::BFGS{LineSearches.InitialStatic{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Nothing, Float32, Flat}, ::Nothing; lower_bounds::Nothing, upper_bounds::Nothing, maxiters::Int64, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ DiffEqFlux ~/.julia/packages/DiffEqFlux/MUw49/src/train.jl:91
 [47] top-level scope
    @ ~/WorkInProgress/ODEswithJulia2021/Week 3/universal_differential_equations/LotkaVolterra/hudson_bay.jl:209
 [48] include(fname::String)
    @ Base.MainInclude ./client.jl:444
 [49] top-level scope
    @ REPL[9]:1
in expression starting at /home/henri/WorkInProgress/ODEswithJulia2021/Week 3/universal_differential_equations/LotkaVolterra/hudson_bay.jl:209
AlCap23 commented 3 years ago

I assume that this has to do with dependencies crashing with each other. The tagged version of MTK should not be dependent on Enzyme ( AFAIK - might have changed recently, @ChrisRackauckas might know something more. ).

This is more on the DiffEqFlux side but has to do with adjusting the sensitivity algorithm's hyperparameters or the optimizers' learning rate.

HenriLaurie commented 3 years ago

Ah thanks. I am in the first place interested because I am using this material for a course I am currently teaching (Julia for ODEs, so I don't mind if one or two cutting edges are very platform-dependent). In the second place, of course, is the basic scientific interest. I commend all of you working on this paper and related projects. It seems to me a fascinating and very promising approach.

ChrisRackauckas commented 3 years ago

The latest DiffEqSensitivity is setup with Enzyme. So you're saying that's giving precompilation issues?

HenriLaurie commented 3 years ago

Yep. A warning (DiffEqFlux precompile, though):

[ Info: Precompiling DiffEqFlux [aae7a2af-3d4f-5e19-a356-7da93b79d9d0]
WARNING: could not import Compiler.EnzymeCtx into Enzyme
ChrisRackauckas commented 3 years ago

But is the code then failing? v1.6?

HenriLaurie commented 3 years ago

v 1.6.2 to be precise. Yes, the warnings are generated by the Pkg...() calls at the start of the file. SOrry, gotta teach

ChrisRackauckas commented 3 years ago

Do you get an error or just a warning?

ChrisRackauckas commented 3 years ago

You got the people's mad at me @wsmoses

HenriLaurie commented 3 years ago

Quick reply -- just a warning