I have update packages for my project and strange error occurs. I have also update Julia from 1.7.2 to 1.8.2.
Previously following code works without problems:
model2 = BSON.load(filepath, @__MODULE__)
Now, I have following error:
ERROR: LoadError: InitError: TypeError: in Type{...} expression, expected UnionAll, got a value of type typeof(Flux.Diagonal)
Stacktrace:
[1] constructtype(T::Function, Ts::Vector{Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\extensions.jl:61
[2] (::BSON.var"#35#36")(d::Dict{Symbol, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\extensions.jl:64
[3] _raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:80
[4] raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:93
[5] (::BSON.var"#23#24"{IdDict{Any, Any}, Module})(x::Dict{Symbol, Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:98
[6] applychildren!(f::BSON.var"#23#24"{IdDict{Any, Any}, Module}, x::Vector{Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\BSON.jl:26
[7] raise_recursive
@ D:\.julia\packages\BSON\73cTU\src\read.jl:98 [inlined]
[8] (::BSON.var"#17#20"{IdDict{Any, Any}, Module})(x::Vector{Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:80
[9] applychildren!(f::BSON.var"#17#20"{IdDict{Any, Any}, Module}, x::Dict{Symbol, Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\BSON.jl:19
--- the last 7 lines are repeated 4 more times ---
[38] _raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:80
[39] raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:93
[40] (::BSON.var"#49#50")(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\extensions.jl:167
[41] raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:92
[42] (::BSON.var"#19#22"{IdDict{Any, Any}, Module})(x::Dict{Symbol, Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:86
[43] applychildren!(f::BSON.var"#19#22"{IdDict{Any, Any}, Module}, x::Dict{Symbol, Any})
@ BSON D:\.julia\packages\BSON\73cTU\src\BSON.jl:19
[44] _raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:86
[45] raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON D:\.julia\packages\BSON\73cTU\src\read.jl:93
[46] raise_recursive
@ D:\.julia\packages\BSON\73cTU\src\read.jl:103 [inlined]
[47] load
@ D:\.julia\packages\BSON\73cTU\src\read.jl:108 [inlined]
[48] (::My_project.var"#31#32"{Dict{Any, Any}})(file::String)
@ My_project D:\Projects\My_project\src\saveload.jl:87
[49] foreach
@ .\abstractarray.jl:2774 [inlined]
[50] loadmodels(dir_name::String)
@ My_project
D:\Projects\My_project\src\src\saveload.jl:83
[51] load_MLmodels()
@ My_project D:\Projects\My_project\src\parameters.jl:66
[52] __init__()
@ My_project D:\Projects\My_project\src\main.jl:46
[53] _include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any})
@ Base .\loading.jl:831
[54] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64)
@ Base .\loading.jl:1039
[55] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1315
[56] _require_prelocked(uuidkey::Base.PkgId)
@ Base .\loading.jl:1200
[57] macro expansion
@ .\loading.jl:1180 [inlined]
[58] macro expansion
@ .\lock.jl:223 [inlined]
[59] require(into::Module, mod::Symbol)
@ Base .\loading.jl:1144
[60] include(mod::Module, _path::String)
@ Base .\Base.jl:419
Solution is to downgrade Flux
package. Problem was with Flux.Diagonal
that is deprecated since Flux@0.13 and now is called Scale