Skip to content

Cannot load pretrained weights for ResNet on master #206

@lorenzoh

Description

@lorenzoh

Package Version

0.8.0-DEV (master)

Julia Version

1.8.3

OS / Environment

] st
Project Metalhead v0.8.0-DEV
Status `~/.julia/dev/Metalhead/Project.toml`
  [fbb218c0] BSON v0.3.6
  [052768ef] CUDA v3.12.0
  [d360d2e6] ChainRulesCore v1.15.6
  [587475ba] Flux v0.13.8
  [d9f16b24] Functors v0.3.0
  [f1d291b0] MLUtils v0.3.1
  [872c559c] NNlib v0.8.10
  [a00861dc] NNlibCUDA v0.2.4
  [570af359] PartialFunctions v1.1.1
  [56f22d72] Artifacts
  [4af54fe1] LazyArtifacts
  [9a3f8284] Random
  [10745b16] Statistics 

Describe the bug

Running

using Metalhead
Metalhead.ResNet(18, pretrain=true)

errors with:

ERROR: ArgumentError: Tried to load (MODEL)
    @ Base ./reduce.jl:58
  [9] foldl_impl
    @ ./reduce.jl:48 [inlined]
 [10] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
 [11] #mapfoldl#259
    @ ./reduce.jl:170 [inlined]
 [12] #foldl#260
    @ ./reduce.jl:193 [inlined]
 [13] foreach
    @ ./tuple.jl:556 [inlined]
 [14] #loadmodel!#352
    @ ~/.julia/packages/Flux/FKl3M/src/loading.jl:91 [inlined]
 [15] (::Flux.var"#353#356"{Flux.var"#354#357", Base.IdSet{Any}, DimensionMismatch})(ldst::Tuple{MODEL})
    @ Flux ~/.julia/packages/Flux/FKl3M/src/loading.jl:98
 [16] foreach(::Function, ::MODEL)
    @ Base ./abstractarray.jl:2775
 [17] loadmodel!(dst::MODEL; filter::Function, cache::Base.IdSet{Any})
    @ Flux ~/.julia/packages/Flux/FKl3M/src/loading.jl:91
 [18] loadmodel!(dst::MODEL)
    @ Flux ~/.julia/packages/Flux/FKl3M/src/loading.jl:84
 [19] loadpretrain!(model::MODEL, name::String)
    @ Metalhead ~/.julia/dev/Metalhead/src/pretrain.jl:26
 [20] ResNet(depth::Int64; pretrain::Bool, inchannels::Int64, nclasses::Int64)
    @ Metalhead ~/.julia/dev/Metalhead/src/convnets/resnets/resnet.jl:26
 [21] top-level scope
    @ REPL[6]:1

Steps to Reproduce

Install master and run the above code.

Expected Results

Expected it to load the weights into the model.

Observed Results

It threw the error.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions