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

Char-LSTM example fails on eval_metric #368

Closed
colbec opened this issue Dec 10, 2017 · 1 comment · Fixed by #370
Closed

Char-LSTM example fails on eval_metric #368

colbec opened this issue Dec 10, 2017 · 1 comment · Fixed by #370

Comments

@colbec
Copy link

colbec commented Dec 10, 2017

The provided example will run completely only if I remove the eval_metric argument from the mx.fit() process. Using:

julia> versioninfo()
Julia Version 0.6.0
Commit 9036443 (2017-06-19 13:05 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

julia> Pkg.status("MXNet")
 - MXNet                         0.0.8+             master (dirty)

The provided example code shows:

mx.fit(model, optimizer, data_tr, eval_data=data_val, n_epoch=N_EPOCH,
       initializer=mx.UniformInitializer(0.1),
       callbacks=[mx.speedometer(), mx.do_checkpoint(CKPOINT_PREFIX)], eval_metric=NLL())

which produces on my machine:

ERROR: LoadError: MethodError: no method matching _update_single_output(::NLL, ::MXNet.mx.NDArray{Float32,1}, ::MXNet.mx.NDArray{Float32,2})
Closest candidates are:
  _update_single_output(!Matched::MXNet.mx.MSE, ::MXNet.mx.NDArray{T,N}, !Matched::MXNet.mx.NDArray{T,N}) where {T, N} at /home/colin/.julia/v0.6/MXNet/src/metric.jl:237
Stacktrace:
 [1] _update!(::NLL, ::Array{MXNet.mx.NDArray{Float32,1},1}, ::Array{MXNet.mx.NDArray{Float32,2},1}, ::Val{true}) at /home/colin/.julia/v0.6/MXNet/src/metric.jl:45
 [2] update!(::NLL, ::Array{MXNet.mx.NDArray{Float32,1},1}, ::Array{MXNet.mx.NDArray{Float32,2},1}) at /home/colin/.julia/v0.6/MXNet/src/metric.jl:34
 [3] #fit#10000(::Array{Any,1}, ::Function, ::MXNet.mx.FeedForward, ::MXNet.mx.ADAM, ::CharSeqProvider) at /home/colin/.julia/v0.6/MXNet/src/model.jl:522
 [4] (::MXNet.mx.#kw##fit)(::Array{Any,1}, ::MXNet.mx.#fit, ::MXNet.mx.FeedForward, ::MXNet.mx.ADAM, ::CharSeqProvider) at ./<missing>:0
 [5] include_from_node1(::String) at ./loading.jl:569
 [6] include(::String) at ./sysimg.jl:14
 [7] process_options(::Base.JLOptions) at ./client.jl:305
 [8] _start() at ./client.jl:371
while loading /home/colin/courses/deeplearn/mxnet/trainlstm.jl, in expression starting on line 39

Removing the eval_metric to rely on the default allows the iteration to perform to a conclusion.

I also get many warnings:
WARNING: Task iteration is now deprecated. Use Channels for inter-task communication. A for-loop on a Channel object is terminated by calling close on the object.

@iblislin
Copy link
Member

diff --git a/examples/char-lstm/lstm.jl b/examples/char-lstm/lstm.jl
index d930240..46f36c2 100644
--- a/examples/char-lstm/lstm.jl
+++ b/examples/char-lstm/lstm.jl
@@ -123,7 +123,7 @@ mutable struct NLL <: mx.AbstractEvalMetric
   NLL() = new(0.0, 0)
 end

-function mx.update!(metric :: NLL, labels :: Vector{mx.NDArray}, preds :: Vector{mx.NDArray})
+function mx.update!(metric::NLL, labels::Vector{<:mx.NDArray}, preds::Vector{<:mx.NDArray})
   @assert length(labels) == length(preds)
   nll = 0.0
   for (label, pred) in zip(labels, preds)

It failed because of this change: #331

iblislin added a commit that referenced this issue Dec 10, 2017
and fix some depwarns

fix #368
iblislin added a commit that referenced this issue Dec 10, 2017
pluskid pushed a commit that referenced this issue Dec 10, 2017
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

Successfully merging a pull request may close this issue.

2 participants