python test.py --ckpt log/1 --d_model=512 --d_ff=1024 Report an error
See original GitHub issueAfter I finished training, I ran the test.py file and reported the following error. I have not solved it, I hope I can get your help. @Kyubyong
` INFO:tensorflow:Restoring parameters from log/1/model_E04-L4.76-49080 INFO:root:# get hypotheses
Traceback (most recent call last): File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 1334, in _do_call return fn(*args) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[125,100] = 100 is not in [0, 100) [[{{node encoder/positional_encoding/embedding_lookup}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “test.py”, line 54, in <module> hypotheses = get_hypotheses(num_test_batches, num_test_samples, sess, y_hat, m.idx2token) File “/mnt/data/xxxx/transformer-master/utils.py”, line 144, in get_hypotheses h = sess.run(tensor) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 929, in run run_metadata_ptr) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 1152, in _run feed_dict_tensor, options, run_metadata) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 1328, in _do_run run_metadata) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/client/session.py”, line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[125,100] = 100 is not in [0, 100) [[node encoder/positional_encoding/embedding_lookup (defined at /mnt/data/xxxx/transformer-master/modules.py:295) ]]
Caused by op ‘encoder/positional_encoding/embedding_lookup’, defined at: File “test.py”, line 41, in <module> y_hat, _ = m.eval(xs, ys) File “/mnt/data/xxxx/transformer-master/model.py”, line 163, in eval memory, sents1 = self.encode(xs, False) File “/mnt/data/xxxx/transformer-master/model.py”, line 50, in encode enc += positional_encoding(enc, self.hp.maxlen1) File “/mnt/data/xxxx/transformer-master/modules.py”, line 295, in positional_encoding outputs = tf.nn.embedding_lookup(position_enc, position_ind) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/ops/embedding_ops.py”, line 316, in embedding_lookup transform_fn=None) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/ops/embedding_ops.py”, line 133, in _embedding_lookup_and_transform result = _clip(array_ops.gather(params[0], ids, name=name), File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/util/dispatch.py”, line 180, in wrapper return target(*args, **kwargs) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py”, line 3273, in gather return gen_array_ops.gather_v2(params, indices, axis, name=name) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py”, line 3748, in gather_v2 “GatherV2”, params=params, indices=indices, axis=axis, name=name) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py”, line 788, in _apply_op_helper op_def=op_def) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py”, line 507, in new_func return func(*args, **kwargs) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 3300, in create_op op_def=op_def) File “/home/ubuntu/anaconda3/envs/deeplearning/lib/python3.6/site-packages/tensorflow/python/framework/ops.py”, line 1801, in init self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): indices[125,100] = 100 is not in [0, 100) [[node encoder/positional_encoding/embedding_lookup (defined at /mnt/data/xxxx /transformer-master/modules.py:295) ]] `
Issue Analytics
- State:
- Created 5 years ago
- Comments:13
The reason is your train parameters and test parameters are not equal, they need same --vocab_size –d_model and --d_ff. Maybe you forgot set parameters when you running test.py.
@Eric217 加你微信了