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

UndefVarError: lib not defined #3

Open
EvergreenTree opened this issue Jan 28, 2020 · 1 comment
Open

UndefVarError: lib not defined #3

EvergreenTree opened this issue Jan 28, 2020 · 1 comment

Comments

@EvergreenTree
Copy link

Hi sorry for bothering if the following bug is trivial. I got this with this example :

𝞗=Dict(:batchsize=>32,:epochs=>80,:ginp=>256,:genh=>[512],:disch=>[512],:optim=>Adam,:lr=>0.0002);
xtrn,ytrn,xtst,ytst = mnist()
global dtrn = minibatch(xtrn, ytrn, 𝞗[:batchsize]; xtype=atype)
global dtst = minibatch(xtst, ytst, 𝞗[:batchsize]; xtype=atype)
𝗪  = (𝗪g,𝗪d)  = initweights(𝞗[:genh], 𝞗[:ginp], 784), initweights(𝞗[:disch], 784, 1)
𝚶  = (𝚶pg,𝚶pd) = optimizers(𝗪g, 𝞗[:optim]; lr=𝞗[:lr]), optimizers(𝗪d,𝞗[:optim]; lr=𝞗[:lr])
generate_and_show(𝗪,100,𝞗)
runmodel(𝗪, dtst, 𝞗; optim=𝚶, train=false) # initial losses
runmodel(𝗪, dtrn, 𝞗; optim=𝚶, train=true, dtst=dtst) # training  

Out:
UndefVarError: lib not defined

Stacktrace:
[1] _broadcasted(::typeof(+), ::KnetArray{Float32,2}, ::KnetArray{Float32,2}, ::KnetArray{Float32,2}, ::Tuple{Tuple{Int64,Int64},Int64,Int64,Int64,Int64,Int64,Int64,Int64,Int64,Bool}) at /home/users/fuch/.julia/packages/Knet/LjPts/src/binary.jl:65
[2] broadcasted(::typeof(+), ::KnetArray{Float32,2}, ::KnetArray{Float32,2}) at /home/users/fuch/.julia/packages/Knet/LjPts/src/binary.jl:43
[3] #mlp#9(::Float64, ::Function, ::Function, ::typeof(mlp), ::Array{Any,1}, ::KnetArray{Float32,2}) at ./In[11]:3
[4] #mlp at ./none:0 [inlined]
[5] #G#11 at ./In[12]:3 [inlined]
[6] G(::Array{Any,1}, ::KnetArray{Float32,2}) at ./In[12]:3
[7] generate_and_show(::Tuple{Array{Any,1},Array{Any,1}}, ::Int64, ::Dict{Symbol,Any}) at ./In[15]:2
[8] top-level scope at In[17]:7

A little bit of debugging shows:

BB = 32
xx = 𝒩(𝞗[:ginp], BB)
# D(𝗪[1],xx)
a = 𝗪[1][1]*mat(xx)
b = 𝗪[1][2]
size(a),size(b)

Out:
((512, 32), (512, 1))

a.+b

Out:
UndefVarError: lib not defined

Stacktrace:
[1] _broadcasted(::typeof(+), ::KnetArray{Float32,2}, ::KnetArray{Float32,2}, ::KnetArray{Float32,2}, ::Tuple{Tuple{Int64,Int64},Int64,Int64,Int64,Int64,Int64,Int64,Int64,Int64,Bool}) at /home/users/fuch/.julia/packages/Knet/LjPts/src/binary.jl:65
[2] broadcasted(::typeof(+), ::KnetArray{Float32,2}, ::KnetArray{Float32,2}) at /home/users/fuch/.julia/packages/Knet/LjPts/src/binary.jl:43
[3] top-level scope at In[56]:1

It seems that broadcasting .+ between array(512,32) and array(512,1) produces this error. could anyone help resolve this? thanks in advance!

@EvergreenTree
Copy link
Author

Nevertheless 'Array(a).+Array(b)' works. I suppose this is a bug of KnetArray

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