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

Error during decoding #52

Closed
neubig opened this issue Apr 24, 2017 · 5 comments
Closed

Error during decoding #52

neubig opened this issue Apr 24, 2017 · 5 comments
Assignees

Comments

@neubig
Copy link
Contributor

neubig commented Apr 24, 2017

Hi,

I ran a super-small experiment training on the dev set from the example Japanese data (see xnmt-small.yaml in mcds-exp.zip) and got the following error. It looks like this might be because search_strategy is outputting NumPy arrays instead of integers at each timestep. Is anyone else getting this problem?

[dynet] random seed: 852191151
[dynet] allocating memory: 512MB
[dynet] memory allocation done.
=> Running ja_check
   > Training   
   Start training in minibatch mode...   
   Epoch 1.0000: train_ppl=372.9873 (words=5057, time=0-00:00:01)   
   Epoch 1.0000: test_ppl=220.3990 (words=5057, time=0-00:00:02)   
   Epoch 1.0000: best dev loss, writing model to xnmtmodel/dev.mod   
   > Evaluating   
   Traceback (most recent call last):
     File "/home/gneubig/work/xnmt/xnmt/xnmt_run_experiments.py", line 123, in <module>
          xnmt_trainer.input_reader.vocab, xnmt_trainer.output_reader.vocab, xnmt_trainer.translator))
     File "/usr0/home/gneubig/work/xnmt/xnmt/xnmt_decode.py", line 52, in xnmt_decode
          target_sentence = output_generator.process(token_string)[0]
     File "/usr0/home/gneubig/work/xnmt/xnmt/output.py", line 32, in process
          self.token_string.append(self.vocab[token])
     File "/usr0/home/gneubig/work/xnmt/xnmt/vocab.py", line 35, in __getitem__
          return self.i2w[i]
   TypeError   :    only integer scalar arrays can be converted to a scalar index   
@psjanani psjanani self-assigned this Apr 24, 2017
@psjanani
Copy link
Collaborator

psjanani commented Apr 24, 2017

Hello sir,
I re-ran with the configurations provided by you on Python 2 and got the following output.

Training
Start training in minibatch mode...
Epoch 1.0000: train_ppl=370.9497 (words=5057, time=0-00:00:01)
Epoch 1.0000: test_ppl=249.1718 (words=5057, time=0-00:00:01)
Epoch 1.0000: best dev loss, writing model to /tmp/dev.mod
Evaluating
bleu: 0.0883409765451
wer: 0.903624733475
Epoch 2.0000: train_ppl=213.6305 (words=5057, time=0-00:00:05)
Epoch 2.0000: test_ppl=208.2777 (words=5057, time=0-00:00:05)
Epoch 2.0000: best dev loss, writing model to /tmp/dev.mod"

@psjanani
Copy link
Collaborator

The current idea is the following:
search_strategy returns the entire list of words (translated sentence) for a source sentence, which is sent to output for processing as a batch (array of array). The token iterator accesses the token ids in the batch. As you pointed out, the above error indicates the case of another dimension being added. But I am unable to reproduce it. Which version of Python is it? I haven't tested the pipeline on Python 3 yet. This was run on the current master branch.

@psjanani
Copy link
Collaborator

psjanani commented Apr 24, 2017

Hi,
This might be due to the change in a recent version of Numpy.
It apparently treats a single-element array as a scalar for the purposes of indexing. That would work against the above idea.
stack overflow
Can you please provide the version of Numpy you are using?

@neubig
Copy link
Contributor Author

neubig commented Apr 24, 2017

Thanks for looking at this so quickly! Here is my info, it's the standard one I got from Anaconda, although the version of anaconda may be old...

(python2) gneubig@lor:~$ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 19 2016, 13:46:45) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as np
>>> print np.__version__
1.12.1

@psjanani
Copy link
Collaborator

@neubig, The error was being caused due to a change in output dimensions returned by concatenate function of the latest dynet. The latest version adds another dimension to the output. We reshape the output now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants