Unable to save simple FLUX model with BSON

Hi,

When I try to save a simple FLUX model like

using Flux, BSON

model = Chain(
    Conv((3, 3), 1=>16, pad=(1,1), relu),
    MaxPool((2,2)),
    Conv((3, 3), 16=>32, pad=(1,1), relu),
    MaxPool((2,2)),
    Conv((3, 3), 32=>32, pad=(1,1), relu),
    MaxPool((2,2)),
    x -> reshape(x, :, size(x, 4)),
    Dense(288, 10),
    softmax,
)

BSON.@save "foo.bson" model

I get

ERROR: LoadError: type Method has no field sparam_syms

I updated to BSON v0.2.4 but this fix did not help me https://github.com/FluxML/Flux.jl/issues/392

Please, do you have any suggestion? Is there a problem with my modest model? I am new to Julia…

Thank you very much!

I attempted to run the code and it works on my machine.
Please, give me the output of

versioninfo()

using Pkg
Pkg.status()

on your machine.

The outputs on my machine:

julia> versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4702MQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

julia> using Pkg

julia> Pkg.status()
    Status `~/.julia/environments/v1.2/Project.toml`
  [c52e3926] Atom v0.10.2
  [fbb218c0] BSON v0.2.4
  [6e4b80f9] BenchmarkTools v0.4.3
  [587475ba] Flux v0.9.0
  [7073ff75] IJulia v1.20.0
  [e5e0dc1b] Juno v0.7.2
  [e88e6eb3] Zygote v0.3.4

Hi! thank you very much for the replay, here is what I get

julia> versioninfo()
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = atom  -a
  JULIA_NUM_THREADS = 4

and

type or paste julia> Pkg.status()
    Status `~/.julia/environments/v1.2/Project.toml`
  [c7e460c6] ArgParse v0.6.2
  [c52e3926] Atom v0.11.0
  [fbb218c0] BSON v0.2.4
  [336ed68f] CSV v0.5.13
  [a93c6f00] DataFrames v0.19.4
  [7806a523] DecisionTree v0.9.0
  [5789e2e9] FileIO v1.0.7
  [587475ba] Flux v0.9.0
  [92fee26a] GZip v0.5.0
  [c27321d9] Glob v1.2.0
  [916415d5] Images v0.17.3
  [e5e0dc1b] Juno v0.7.2
  [1902f260] Knet v1.2.7
  [eb30cadb] MLDatasets v0.4.0
  [dbeba491] Metalhead v0.3.0
  [91a5bcdd] Plots v0.27.0
  [438e738f] PyCall v1.91.2
  [dca85d43] QuartzImageIO v0.6.0
  [3646fa90] ScikitLearn v0.5.1
  [9a3f8284] Random 
  [10745b16] Statistics code here

If it helps, the error I get is

type or pastjulia> BSON.@save "foo.bson" model
ERROR: type Method has no field sparam_syms
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./Base.jl:20
 [2] structdata(::Method) at /Users/rio/.julia/packages/BSON/XPZLD/src/anonymous.jl:3
 [3] lower(::Method) at /Users/rio/.julia/packages/BSON/XPZLD/src/extensions.jl:86
 [4] _lower_recursive(::Method, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [5] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Method) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [6] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:28
 [7] _lower_recursive(::Array{Method,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [8] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Array{Method,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [9] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:28
 [10] _lower_recursive(::Array{Any,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [11] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [12] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:28
 [13] _lower_recursive(::Array{Any,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [14] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [15] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:21
 [16] _lower_recursive(::Core.TypeName, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [17] (::getfield(BSON, Symbol("##5#9")){IdDict{Any,Any},Array{Any,1}})(::Core.TypeName) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:53
 [18] applychildren!(::getfield(BSON, Symbol("##5#9")){IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:21
 [19] (::getfield(BSON, Symbol("#_lower#8")){IdDict{Any,Any},Array{Any,1}})(::Type) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:53
 [20] _lower_recursive(::Type, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:54
 [21] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Type) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [22] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:28
 [23] _lower_recursive(::Array{DataType,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [24] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Array{DataType,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [25] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:21
 [26] _lower_recursive(::Type, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [27] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Type) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [28] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:28
 [29] _lower_recursive(::Array{DataType,1}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [30] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Array{DataType,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [31] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:21
 [32] _lower_recursive(::Type, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [33] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Type) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [34] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:21
 [35] _lower_recursive(::Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [36] (::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}})(::Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [37] applychildren!(::getfield(BSON, Symbol("##7#11")){IdDict{Any,Any},Array{Any,1}}, ::Dict{Symbol,Any}) at /Users/rio/.julia/packages/BSON/XPZLD/src/BSON.jl:21
 [38] _lower_recursive(::Dict{Symbol,Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}}, ::IdDict{Any,Any}, ::Array{Any,1}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:62
 [39] lower_recursive(::Dict{Symbol,Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:73
 [40] bson(::IOStream, ::Dict{Symbol,Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:81
 [41] #14 at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:83 [inlined]
 [42] #open#312(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(open), ::getfield(BSON, Symbol("##14#15")){Dict{Symbol,Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}}}, ::String, ::Vararg{String,N} where N) at ./iostream.jl:375
 [43] open at ./iostream.jl:373 [inlined]
 [44] bson(::String, ::Dict{Symbol,Chain{Tuple{Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},Conv{2,2,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},MaxPool{2,4},getfield(Main, Symbol("##9#10")),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}}}) at /Users/rio/.julia/packages/BSON/XPZLD/src/write.jl:83
 [45] top-level scope at none:0
e code here

Any suggestion? Thank you!