Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodError: no method matching length(::Nothing) #498

Closed
praveenyati10 opened this issue Mar 4, 2021 · 3 comments · Fixed by #499
Closed

MethodError: no method matching length(::Nothing) #498

praveenyati10 opened this issue Mar 4, 2021 · 3 comments · Fixed by #499

Comments

@praveenyati10
Copy link

Was trying to predict parameters for duffing equation using BlackBoxOptim. It worked in julia 1.5.1 but not working in julia 1.5.3
and throwing error-**MethodError: no method matching length(::Nothing)**

using BlackBoxOptim

using Optim

function loss(p)
        tmp_prob=remake(prob,p=p)
        tmp_sol=solve(tmp_prob,MethodOfSteps(Tsit5()),p=p,saveat=0.01)
        sum(abs2,Array(tmp_sol)-dataset),tmp_sol
end



pinit=[1.0,1.0,0.5]
res3=DiffEqFlux.sciml_train(loss,pinit,DiffEqFlux.BBO(),lower_bounds=0.0ones(4),upper_bounds=4.0ones(4))

@ChrisRackauckas
Copy link
Member

I can't run that.

@praveenyati10
Copy link
Author

okay let me upload the whole code

using Pkg

Pkg.add("BlackBoxOptim")

using DiffEqFlux

function duffing(du,u,p,t)
 γ,d,ω=p
 du[1] = u[2]
 du[2] = u[1] - u[1]^3 -γ*u[2] + d*cos(ω*t)
end

p=[.1,.1,1.4]
u0 = [1.0; -1.0]
tspan = (0.0,50.0)

Δt = 1e-2
T = tspan[1]:Δt:tspan[end]

prob = ODEProblem(duffing, u0, tspan,p)
sol =solve(prob,MethodOfSteps(Tsit5()),p=p,saveat=0.01)
sol
plot(sol[1,:])
dataset=Array(sol)
dataset
function loss(p)
        tmp_prob=remake(prob,p=p)
        tmp_sol=solve(tmp_prob,MethodOfSteps(Tsit5()),p=p,saveat=0.01)
        sum(abs2,Array(tmp_sol)-dataset),tmp_sol
end

using BlackBoxOptim

using Optim

pinit=[1.0,1.0,0.5]
res3=DiffEqFlux.sciml_train(loss,pinit,DiffEqFlux.BBO(),lower_bounds=0.0ones(4),upper_bounds=4.0ones(4))
res3

`
```

@ChrisRackauckas ChrisRackauckas transferred this issue from SciML/DifferentialEquations.jl Mar 4, 2021
ChrisRackauckas added a commit that referenced this issue Mar 4, 2021
@ChrisRackauckas
Copy link
Member

The fix is in #499 and should merge tomorrow.

ChrisRackauckas added a commit that referenced this issue Mar 4, 2021
* fix bounds translation

fixes #498

* patch release
Parvfect added a commit to Parvfect/DiffEqFlux.jl that referenced this issue Mar 29, 2022
Considering the amount of code rewritten, it makes more sense to define it as a struct or purely define one ff layer that encapsulates a fourier feature encoding and dense layers and then have a different file where users can create msff networks using FastChains or a new file for Networks that are defined using general FastChains. 

Addtionally, bias is not included because of my lack of understanding of including it in a solitary function. 
It has not been rigirously tested, although it seems to compile.  I did get an inexact error that I couldn't debug when trying to run some operations, I would need some help to tackle the issue now that I know the general way that the network can be implemented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants