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: Cannot convert an object of type Params to an object of type Float64 #1629

Closed
paritosh5feb opened this issue Jun 25, 2021 · 1 comment

Comments

@paritosh5feb
Copy link

This is my model, a CNN for Image segmentation. I wrote after an article from this:- https://dev.to/yunshu67/lenet-implementation-for-cell-segmentation-105e

But I am getting an error as mentioned after the code.

`function leNet5()
return Chain(
convBlock(10,10),
MeanPool((5,5)),
convBlock(20,20),
MeanPool((5,5)),
flatten,
Dense(20,40),
Dense(40,80),
Dense(80,100))
end

m = leNet5()
p = params(m)
loss(x, y) = crossentropy(m(x), y)
opt = ADAM(p)
epochs = 10`

Error:-

MethodError: Cannot convert an object of type Params to an object of type Float64
Closest candidates are:
convert(::Type{Float64}, ::LLVM.ConstantFP) at /home/jupyterlab/.julia/packages/LLVM/KITdB/src/core/value/constant.jl:85
convert(::Type{T<:AbstractFloat}, ::Ratios.SimpleRatio{S}) where {T<:AbstractFloat, S} at /home/jupyterlab/.julia/packages/Ratios/uRs4y/src/Ratios.jl:14
convert(::Type{T<:Number}, ::T<:Number) where T<:Number at number.jl:6
...

Stacktrace:
[1] ADAM(::Params, ::Tuple{Float64,Float64}, ::IdDict{Any,Any}) at /home/jupyterlab/.julia/packages/Flux/NpkMm/src/optimise/optimisers.jl:159
[2] ADAM(::Params, ::Tuple{Float64,Float64}) at /home/jupyterlab/.julia/packages/Flux/NpkMm/src/optimise/optimisers.jl:164 (repeats 2 times)
[3] top-level scope at

@CarloLucibello
Copy link
Member

Usage questions on the package are better asked on discourse instead of here.
The problem in your example is that you don't have to feed the params to the optimizer.
Please check the documentation.

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

No branches or pull requests

2 participants