denizyuret / AutoGrad.jl

Julia port of the Python autograd package.
Other
169 stars 26 forks source link

objects of type AutoGrad.Result{KnetArray{Float32,2}} are not callable #95

Closed yashbha closed 6 years ago

yashbha commented 6 years ago

I am getting the following error when I am implementing a Knet model.

ERROR: LoadError: MethodError: objects of type AutoGrad.Result{KnetArray{Float32,2}} are not callable
Stacktrace:
 [1] #differentiate#3(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Param{Array{KnetArray{Float32,N} where N,1}}, ::Vararg{Any,N} where N) at C:\Users\user\.julia\packages\AutoGrad\Vt8aS\src\core.jl:56
 [2] differentiate(::Function, ::Param{Array{KnetArray{Float32,N} where N,1}}, ::Vararg{Any,N} where N) at C:\Users\user\.julia\packages\AutoGrad\Vt8aS\src\core.jl:43
 [3] (::getfield(AutoGrad, Symbol("##gradfun#6#7")){typeof(loss),Int64,Bool})(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Array{KnetArray{Float32,N} where N,1}, ::Vararg{Any,N} where N) at C:\Users\user\.julia\packages\AutoGrad\Vt8aS\src\core.jl:127
 [4] (::getfield(AutoGrad, Symbol("#gradfun#8")){getfield(AutoGrad, Symbol("##gradfun#6#7")){typeof(loss),Int64,Bool}})(::Array{KnetArray{Float32,N} where N,1}, ::Vararg{Any,N} where N) at C:\Users\user\.julia\packages\AutoGrad\Vt8aS\src\core.jl:123
 [5] #epoch!#26(::Int64, ::Function, ::Array{KnetArray{Float32,N} where N,1}, ::Array{Any,1}, ::Array{Momentum,1}, ::Array{Float32,4}, ::Array{Any,1}) at C:\Users\user\Documents\julia projects\testme.jl:258
 [6] epoch!(::Array{KnetArray{Float32,N} where N,1}, ::Array{Any,1}, ::Array{Momentum,1}, ::Array{Float32,4}, ::Array{Any,1}) at C:\Users\user\Documents\julia projects\testme.jl:254
 [7] #train#30(::Type, ::Int64, ::Float64, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function) at C:\Users\user\Documents\julia projects\testme.jl:287
 [8] train() at C:\Users\user\Documents\julia projects\testme.jl:277
 [9] top-level scope at none:0
 [10] include_string(::Module, ::String, ::String) at .\loading.jl:1002
 [11] (::getfield(Atom, Symbol("##118#123")){String,String,Module})() at C:\Users\user\.julia\packages\Atom\WSz3k\src\eval.jl:120
 [12] withpath(::getfield(Atom, Symbol("##118#123")){String,String,Module}, ::String) at C:\Users\user\.julia\packages\CodeTools\8CjYJ\src\utils.jl:30
 [13] withpath at C:\Users\user\.julia\packages\Atom\WSz3k\src\eval.jl:46 [inlined]
 [14] #117 at C:\Users\user\.julia\packages\Atom\WSz3k\src\eval.jl:117 [inlined]
 [15] hideprompt(::getfield(Atom, Symbol("##117#122")){String,String,Module}) at C:\Users\user\.julia\packages\Atom\WSz3k\src\repl.jl:76
 [16] macro expansion at C:\Users\user\.julia\packages\Atom\WSz3k\src\eval.jl:116 [inlined]
 [17] (::getfield(Atom, Symbol("##116#121")){Dict{String,Any}})() at .\task.jl:85
in expression starting at C:\Users\user\Documents\julia projects\testme.jl:292
denizyuret commented 6 years ago

Can you share the lines in your code that causes this issue? (testme.jl:254-258 neighborhood)

yashbha commented 6 years ago
function epoch!(w, m, o, xtrn, ytrn;  mbatch=64)
    data = minibatch(xtrn, ytrn, mbatch;
                   shuffle=true,
                   xtype=atype())
    for (x, y) in data
        g = lossgrad(w, m, x, y)
        update!(w, g, o)
    end
end

I am using the same code as in Knet.jl examples: cnn-batchnorm. I had very recently raised an issue in Knet github. about the same code- https://github.com/denizyuret/Knet.jl/issues/353#issuecomment-421101231

ilkerkesen commented 6 years ago

There's no unexpected behavior. Feel free the open this issue and the other one, if the answer does not satisfy you.