BSON confusing behaviour

Apologies for so many questions in so short a time, but I have decided to do a “push”, so I am tackling the issues in sequence (and there are alot of them).

Regarding using BSON to load: Here is an example of trying to load a model:

using BSON

Dict{Symbol,Any} with 1 entry:
:dict1 => Dict(“mw”=>Chain(Dense(68, 5), BatchNorm(5, <\lambda> = relu), Dense(5, 5),…

UndefVarError: dict1 not defined

Following instructions for BSON, I had saved the dictionary dict1, and (apparently) loaded it successfully, but when I tried to access it, it is not there.

Can anyone help please?

It is unlikely that BSON.load defines a local variable. You would need to do something like:*

using BSON
data = BSON.load("/home/davide/france/julia_scripts/nntest.jls")
dict1 = data[:dict1]
mw = dict1["mw"]

Thanks Kristoffer.

Actually, I had saved it using BSON.@save and had tried BSON.@load
and that had worked in the ‘intuitive’ way above (with dict1 just appearing) at the time, but it has stopped working that way.

Yes - your way works - thanks! I had tried data[“dict1”] and don’t know why the colon appeared or why it is necessary and why quotes aren’t necessary, but I guess I’ll just have to remember it. Thanks.

**** Update **** most issues I have had with this seem to relate to differing types of objects saved by different versions of Flux (models from v0.9.0 and v0.10.1 are not the same types of objects). Also a bit of confusion going back and forth between and BSON.@save/@load