JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.1k stars 214 forks source link

Bounds Error in Neural Network Training Process #1091

Closed CatYukino closed 2 months ago

CatYukino commented 3 months ago

Hi. I'm using Optim.jl to train a neural ODE, while it always appears some bounds errors like:

ERROR: BoundsError: attempt to access 13-element Vector{Float64} at index [1:200]

I checked the code and found that it appeared when I used BFGS and LBFGS. I firstly used ADAM and it worked well, while it converges slowly, which means the time cost is too large... So I chose (L)BFGS and some other second order algorithms, while the boundserror always occurred. I wonder if the design of the model is too complex(in fact there is warning that the problem is stiff), or is there any other choices to solve the problem?

Thanks!

pkofod commented 2 months ago

It is very hard to say without more information. From my own experience, it could be that your model did not solve and you did not account for the unfinished state inside the solution option? So if you do sol.u it may not be completely allocated if you're not certain that the model retcode was succes.

I will close it, but if it is an Optim issue, please supply more of the stack trace so I can see where the error is thrown and reopen.