Skip to content

BSON.@save model_path * ".bson" model ERROR: type Method has no field ambig #1591

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

Closed
VoSiLk opened this issue May 5, 2021 · 6 comments
Closed

Comments

@VoSiLk
Copy link

VoSiLk commented May 5, 2021

However, I get sometime weird errors when I try to save flux models. I'm not sure if it has some relation in which scope I would like to it. In other words, if I try to save in a script (global scope, it works) or in a function (function scope, it doesn't work).

push!(layers, Flux.Recur(Flux.LSTMCell(Float32.(W'), Float32.(U'), Float32.(b), (zeros(Float32, Int(length(b)/4),1), zeros(Float32, Int(length(b)/4),1))  )))

model = Chain(layers..., x -> reshape(x, :))

> model
Chain(Recur(LSTMCell(4, 80)), Recur(LSTMCell(80, 80)), Recur(LSTMCell(80, 80)), Recur(LSTMCell(80, 80)), Dense(80, 1, relu), #7)

BSON.@save model_path * ".bson" model
ERROR: type Method has no field ambig
Stacktrace:
  [1] getproperty(x::Method, f::Symbol)
    @ Base .\Base.jl:33
  [2] structdata(meth::Method)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\anonymous.jl:15
  [3] lower(x::Method)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\extensions.jl:92
  [4] _lower_recursive(x::Method, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
  [5] (::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}})(x::Method)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
  [6] applychildren!(f::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}}, x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:28
  [7] _lower_recursive(x::Vector{Method}, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
  [8] (::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}})(x::Vector{Method})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
  [9] applychildren!(f::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}}, x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:28
 [10] _lower_recursive(x::Vector{Any}, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [11] (::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}})(x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [12] applychildren!(f::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}}, x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:28
 [13] _lower_recursive(x::Vector{Any}, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [14] (::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}})(x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [15] applychildren!(f::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}}, x::Dict{Symbol, Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:21
 [16] _lower_recursive(x::Core.TypeName, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [17] (::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}})(x::Core.TypeName)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [18] applychildren!(f::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}}, x::Dict{Symbol, Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:21
 [19] (::BSON.var"#_lower#6"{IdDict{Any, Any}, Vector{Any}})(x::Type)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [20] _lower_recursive(x::Type, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:54
 [21] (::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}})(x::Type)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [22] applychildren!(f::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}}, x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:28
 [23] _lower_recursive(x::Vector{DataType}, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [24] (::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}})(x::Vector{DataType})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [25] applychildren!(f::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}}, x::Dict{Symbol, Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:21
 [26] (::BSON.var"#_lower#6"{IdDict{Any, Any}, Vector{Any}})(x::Type)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [27] _lower_recursive(x::Type, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:54
 [28] (::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}})(x::Type)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [29] applychildren!(f::BSON.var"#5#9"{IdDict{Any, Any}, Vector{Any}}, x::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:28
 [30] _lower_recursive(x::Vector{DataType}, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:62
 [31] (::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}})(x::Vector{DataType})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [32] applychildren!(f::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}}, x::Dict{Symbol, Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:21
 [33] (::BSON.var"#_lower#6"{IdDict{Any, Any}, Vector{Any}})(x::Type)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [34] _lower_recursive(x::Type, cache::IdDict{Any, Any}, refs::Vector{Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:54
 [35] (::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}})(x::Type)
    @ BSON ~\.julia\packages\BSON\hHtRU\src\write.jl:53
 [36] applychildren!(f::BSON.var"#3#7"{IdDict{Any, Any}, Vector{Any}}, x::Dict{Symbol, Any})
    @ BSON ~\.julia\packages\BSON\hHtRU\src\BSON.jl:21
@DhairyaLGandhi
Copy link
Member

I think you need literal strings too

@darsnack
Copy link
Member

darsnack commented May 5, 2021

ambig issue was fixed in JuliaIO/BSON.jl#94. Do you have the latest BSON release?

@VoSiLk
Copy link
Author

VoSiLk commented May 5, 2021

I worked on BSON v0.3.2. I now have tested it with v 0.3.3 and it works

@darsnack
Copy link
Member

darsnack commented May 5, 2021

Just to clarify this means there is no error on BSON v0.3.3?

@VoSiLk
Copy link
Author

VoSiLk commented May 6, 2021

yes no errror

@DhairyaLGandhi
Copy link
Member

Cool!

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

3 participants