-
-
Notifications
You must be signed in to change notification settings - Fork 65
ResNet pretained does not load #287
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
Comments
It seems to be an issue with Flux.jl loadmodel! changes v0.15 FluxML/Flux.jl#2584 |
I think this issue has been fixed in FluxML/Flux.jl#2598. |
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.5 (2025-04-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(@v1.11) pkg> st
Status `~/.julia/environments/v1.11/Project.toml`
[587475ba] Flux v0.16.3 `https://github.com/FluxML/Flux.jl.git#master`
[dbeba491] Metalhead v0.9.5 `https://github.com/FluxML/Metalhead.jl.git#master`
Info Packages marked with ⌃ have new versions available and may be upgradable.
julia> using Flux, Metalhead
julia> model = ResNet(18; pretrain=true, nclasses=10)
ERROR: ArgumentError: Tried to load Base.OneTo(0) into (:args, :expr_string, :func, :kwargs) but the structures do not match.
Stacktrace:
[1] loadmodel!(dst::Function, src::Tuple{}; filter::Function, cache::IdSet{Any})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:95
[2] loadmodel!(dst::Parallel{…}, src::@NamedTuple{…}; filter::Function, cache::IdSet{…})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[3] loadmodel!
@ ~/.julia/packages/Flux/6pNhw/src/loading.jl:90 [inlined]
[4] loadmodel!(dst::Tuple{…}, src::Tuple{…}; filter::Function, cache::IdSet{…})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[5] loadmodel!(dst::Chain{Tuple{…}}, src::@NamedTuple{layers::Tuple{…}}; filter::Function, cache::IdSet{Any})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[6] loadmodel!(dst::Tuple{…}, src::Tuple{…}; filter::Function, cache::IdSet{…})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[7] loadmodel!(dst::Chain{Tuple{…}}, src::@NamedTuple{layers::Tuple{…}}; filter::Function, cache::IdSet{Any})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[8] loadmodel!(dst::Tuple{…}, src::Tuple{…}; filter::Function, cache::IdSet{…})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[9] loadmodel!(dst::Chain{Tuple{…}}, src::@NamedTuple{layers::Tuple{…}}; filter::Function, cache::IdSet{Any})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[10] loadmodel!(dst::ResNet, src::@NamedTuple{layers::@NamedTuple{layers::Tuple{…}}}; filter::Function, cache::IdSet{Any})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:105
[11] loadmodel!(dst::ResNet, src::@NamedTuple{layers::@NamedTuple{layers::Tuple{@NamedTuple{…}, @NamedTuple{…}}}})
@ Flux ~/.julia/packages/Flux/6pNhw/src/loading.jl:90
[12] loadpretrain!(model::ResNet, artifact_name::String)
@ Metalhead ~/.julia/packages/Metalhead/lxP8T/src/pretrain.jl:57
[13] ResNet(depth::Int64; pretrain::Bool, inchannels::Int64, nclasses::Int64)
@ Metalhead ~/.julia/packages/Metalhead/lxP8T/src/convnets/resnets/resnet.jl:33
[14] top-level scope
@ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types. Unfortunately, I still have the error using the main Flux.jl, and Metalhead.jl, branch |
Flux 0.14 julia> model = ResNet(18; pretrain=false, nclasses=10)
ResNet(
Chain(
Chain(
Chain(
Conv((7, 7), 3 => 64, pad=3, stride=2, bias=false), # 9_408 parameters
BatchNorm(64, relu), # 128 parameters, plus 128
MaxPool((3, 3), pad=1, stride=2),
),
Chain(
Parallel(
addact(NNlib.relu, ...),
identity,
Chain( Flux 0.16 julia> model = ResNet(18; pretrain=false, nclasses=10)
ResNet(
Chain(
Chain(
Chain(
Conv((7, 7), 3 => 64, pad=3, stride=2, bias=false), # 9_408 parameters
BatchNorm(64, relu), # 128 parameters, plus 128
MaxPool((3, 3), pad=1, stride=2),
),
Chain(
Parallel(
PartialFunction(
"",
Metalhead.addact,
(relu,),
NamedTuple(),
),
identity,
Chain( In both cases: Metalhead v0.9.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Julia 1.11.3 and Metalhead v0.9.5 ResNet would fail to load,
The text was updated successfully, but these errors were encountered: