Nmt: Fail to run "Hands-on – building an attention-based NMT model"

Created on 9 Oct 2017  Â·  8Comments  Â·  Source: tensorflow/nmt

I am able to train, and built the inference using the basic steps (running with /tmp/nmt_model). However, when following steps to train and build "attention-based" model, I got the exception about "All values in memory_sequence_length must greater than zero"

Anyone has an idea why and how to fix that?
Thanks .

...
Start decoding
decoding to output /tmp/nmt_model/output_infer.
Traceback (most recent call last):
File "/home/pdo1/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
return fn(*args)
File "/home/pdo1/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
status, run_metadata)
File "/home/pdo1/anaconda3/lib/python3.5/contextlib.py", line 66, in __exit__
next(self.gen)
File "/home/pdo1/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 467, in raise_exception_on_not_ok_status
c_api.TF_GetCode(status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [All values in memory_sequence_length must greater than zero.] [Condition x > 0 did not hold element-wise:] [x (IteratorGetNext:1) = ] [48 45 37...]
[[Node: dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert = Assert[T=[DT_STRING, DT_STRING, DT_STRING, DT_INT32], summarize=3, _device="/job:localhost/replica:0/task:0/device:CPU:0"](dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/All, dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert/data_0, dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert/data_1, dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert/data_2, dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Less/Enter)]]

Most helpful comment

I run training with "python -m nmt.nmt --attention=scaled_luong --src=ja --tgt=vi --vocab_prefix=/home/ngovinh/nmt/nmt/corpus/vocab --train_prefix=/home/ngovinh/nmt/nmt/corpus/train --dev_prefix=/home/ngovinh/nmt/nmt/corpus/dev --test_prefix=/home/ngovinh/nmt/nmt/corpus/test --out_dir=/data/ngovinh/nmt-attention --src_max_len=80 --tgt_max_len=80 --num_train_steps=12000 --steps_per_stats=100 --num_layers=2 --num_units=128 --dropout=0.2 --metrics=bleu 1"
and then I get error after 1000 step as follow:
InvalidArgumentError (see above for traceback): assertion failed: [All values in memory_sequence_length must greater than zero.] [Condition x > 0 did not hold element-wise:] [x (IteratorGetNext:1) = ] [25 54 28...]

I have checked all file of data, but they don't have any empty line. I do not know why? can anyone help me?
thanks,

All 8 comments

Hi @janoct,

You may have a zero length sequence (empty line) in your inference input
file. The attention module doesn’t support zero length input sequence.

Thanks

On Mon, Oct 9, 2017 at 4:19 PM janoct notifications@github.com wrote:

I am able to train, and built the inference using the basic steps (running
with /tmp/nmt_model). However, when following steps to train and build
"attention-based" model, I got the exception about "All values in
memory_sequence_length must greater than zero"

Anyone has an idea why and how to fix that?
Thanks .

...
Start decoding
decoding to output /tmp/nmt_model/output_infer.
Traceback (most recent call last):
File
"/home/pdo1/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py",
line 1323, in _do_call
return fn(args)
File
"/home/pdo1/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py",
line 1302, in _run_fn
status, run_metadata)
File "/home/pdo1/anaconda3/lib/python3.5/contextlib.py", line 66, in
*exit

next(self.gen)
File
"/home/pdo1/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py",
line 467, in raise_exception_on_not_ok_status
c_api.TF_GetCode(status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion
failed: [All values in memory_sequence_length must greater than zero.]
[Condition x > 0 did not hold element-wise:] [x (IteratorGetNext:1) = ] [48
45 37...]
[[Node:
dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert
= Assert[T=[DT_STRING, DT_STRING, DT_STRING, DT_INT32], summarize=3,
_device="/job:localhost/replica:0/task:0/device:CPU:0"](dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/All,
dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert/data_0,
dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert/data_1,
dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Assert/Assert/data_2,
dynamic_seq2seq/decoder/decoder/while/BasicDecoderStep/decoder/attention/assert_positive/assert_less/Less/Enter)]]

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/nmt/issues/140, or mute the thread
https://github.com/notifications/unsubscribe-auth/AEZCMJjb6w4ZNXp77SvUTylVvSMttK94ks5sqn-lgaJpZM4PzAUk
.

Probably not... the inference file (/tmp/my_infer_file.vi) has content in it, and in fact, I used the same file when running basic command, and got good output.

python -m nmt.nmt --out_dir=/tmp/nmt_model --inference_input_file=/tmp/my_infer_file.vi --inference_output_file=/tmp/nmt_model/output_infer

Hi @janoct

I think the basic seq2seq model can deal with zero length sequence since it doesn't use attention mechanism.

For you inference_input_file, each line is an input sequence, if you have something like the following in the file, that will break the attention mechanism. The empty line between first and third line will be fed in as a zero length sequence.

First sentence ...

Third sentence ...

Thanks @oahziur. That is the reason. I do have extra empty line at the end of the file. Thanks so much for pointing it out.

I run training with "python -m nmt.nmt --attention=scaled_luong --src=ja --tgt=vi --vocab_prefix=/home/ngovinh/nmt/nmt/corpus/vocab --train_prefix=/home/ngovinh/nmt/nmt/corpus/train --dev_prefix=/home/ngovinh/nmt/nmt/corpus/dev --test_prefix=/home/ngovinh/nmt/nmt/corpus/test --out_dir=/data/ngovinh/nmt-attention --src_max_len=80 --tgt_max_len=80 --num_train_steps=12000 --steps_per_stats=100 --num_layers=2 --num_units=128 --dropout=0.2 --metrics=bleu 1"
and then I get error after 1000 step as follow:
InvalidArgumentError (see above for traceback): assertion failed: [All values in memory_sequence_length must greater than zero.] [Condition x > 0 did not hold element-wise:] [x (IteratorGetNext:1) = ] [25 54 28...]

I have checked all file of data, but they don't have any empty line. I do not know why? can anyone help me?
thanks,

I run training with "python -m nmt.nmt --attention=scaled_luong --src=ja --tgt=vi --vocab_prefix=/home/ngovinh/nmt/nmt/corpus/vocab --train_prefix=/home/ngovinh/nmt/nmt/corpus/train --dev_prefix=/home/ngovinh/nmt/nmt/corpus/dev --test_prefix=/home/ngovinh/nmt/nmt/corpus/test --out_dir=/data/ngovinh/nmt-attention --src_max_len=80 --tgt_max_len=80 --num_train_steps=12000 --steps_per_stats=100 --num_layers=2 --num_units=128 --dropout=0.2 --metrics=bleu 1"
and then I get error after 1000 step as follow:
InvalidArgumentError (see above for traceback): assertion failed: [All values in memory_sequence_length must greater than zero.] [Condition x > 0 did not hold element-wise:] [x (IteratorGetNext:1) = ] [25 54 28...]

I have checked all file of data, but they don't have any empty line. I do not know why? can anyone help me?
thanks,

maybe your file have unmatched source target corpus, please check

@fooSynaptic you meant different number of lines between the source target corpus?

@oahziur can there be an input with multiple space between tokens i.e. a b?

As an example:

cat dog elephant
a day in    the zoo
this is hard

there are multiple spaces in the second sentence. will the attention model be able to handle this issue?

Was this page helpful?
0 / 5 - 0 ratings