Skip to content
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

BSON error when used to load weights in module / package #52

Open
Ayushk4 opened this issue Aug 12, 2019 · 0 comments
Open

BSON error when used to load weights in module / package #52

Ayushk4 opened this issue Aug 12, 2019 · 0 comments

Comments

@Ayushk4
Copy link
Contributor

Ayushk4 commented Aug 12, 2019

I am trying something like the following and the error I get is ERROR: UndefVarError: Tracker not defined

Steps to replicate this -

  1. Let ExampleModule.jl file be the following
module ExampleModule
   using BSON, Tracker, Flux
   include("./file1.jl")
end
  1. And here is the code in file1.jl
function load_weights(path) # Loading weights
    c = BSON.load(path)
    return c
end
  1. Create and save weights like using Flux; using BSON: @save;, w = param(rand(2,2)) and then @save "wt.bson" w.
  2. In a new REPL session , if I do the following -
julia> include("ExampleModule.jl")

julia> ExampleModule.load_weights("wt.bson")
ERROR: UndefVarError: Tracker not defined

It throws an error. The same thing happens if w in step 3. is replaced by Flux.Conv as well.
Also if I do using Tracker, Flux at the top level (i.e. in REPL session - step 4.) this starts working fine. Exporting Tracker and Flux also work fine, except for the tests.

The above example is a simplified version to recreate the error I am facing in JuliaText/TextAnalysis.jl#167

Other Info

Flux v0.8.3
BSON v0.2.3
Julia 1.0.3
OS - Ubuntu 18.04.2 LTS - 64-bit although with Travis CI, doesn't work on osx.

From the looks of it, BSON searches for Tracker and Flux at the topmost level. Am I missing something here?

@Ayushk4 Ayushk4 changed the title BSON error when used in Module BSON error when used to load weights in module / package Aug 12, 2019
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

1 participant