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

关于项目的运行 #2

Open
17385 opened this issue Feb 6, 2020 · 7 comments
Open

关于项目的运行 #2

17385 opened this issue Feb 6, 2020 · 7 comments

Comments

@17385
Copy link

17385 commented Feb 6, 2020

我在命令行输入:python run.py HS-B 运行您的代码的时出现错误:
InvalidArgumentError (see above for traceback): indices[29,26,0] = 292 is not in [0, 292)
[[node embedding_lookup_6 (defined at E:\TreeGen-master\code_generate_model.py:677) ]]

code_generate_model.py中
new_m = common_layers.cast_like(new_m, var)报错 Unresolved reference 'common_layers'

(依赖包已经全部装好,我的使用的系统环境是win10。)
想请问您如何解决这个问题,并完整运行整个项目。

@zysszy
Copy link
Owner

zysszy commented Feb 6, 2020

您好,
求问一下详细的报错,我这边运行是没有错误的。
谢谢~

@17385
Copy link
Author

17385 commented Feb 7, 2020

详细的报错:
raceback (most recent call last):
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call
return fn(*args)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_session
run
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,26,0] = 292 is not in [0, 292)
[[{{node embedding_lookup_6}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "run.py", line 302, in
main()
File "run.py", line 300, in main
run()
File "run.py", line 245, in run
ac1, loss1, _ = g_eval(sess, Code_gen_model, valid_batch[k])
File "run.py", line 207, in g_eval
model.is_train: False
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 929, in run
run_metadata_ptr)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_run
run_metadata)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\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[22,26,0] = 292 is not in [0, 292)
[[node embedding_lookup_6 (defined at E:\TreeGen-master\code_generate_model.py:677) ]]

Caused by op 'embedding_lookup_6', defined at:
File "run.py", line 302, in
main()
File "run.py", line 300, in main
run()
File "run.py", line 225, in run
batch_size, NL_vocabu_size, Tree_vocabu_size, NL_len, Tree_len, parent_len, learning_rate, keep_prob, len(char_vocabulary), rules_l
en)
File "E:\TreeGen-master\code_generate_model.py", line 677, in init
em_Rule_Son = tf.nn.embedding_lookup(self.Tree_embedding, self.inputrulelistson)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\embedding_ops.py", line 316, in embedding_look
up
transform_fn=None)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\embedding_ops.py", line 133, in _embedding_loo
kup_and_transform
result = _clip(array_ops.gather(params[0], ids, name=name),
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\array_ops.py", line 3273, in gather
return gen_array_ops.gather_v2(params, indices, axis, name=name)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 4390, in gather_v2
"GatherV2", params=params, indices=indices, axis=axis, name=name)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in apply
op_helper
op_def=op_def)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 3300, in create_op
op_def=op_def)
File "C:\Users\17385\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1801, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): indices[22,26,0] = 292 is not in [0, 292)
[[node embedding_lookup_6 (defined at E:\TreeGen-master\code_generate_model.py:677) ]]

但是我修改run.py中的Tree_vocabu_size = len(tree_vocabulary)+1 #len(tree_vocabulary)后,训练可以继续下去了,这样可以吗?
谢谢您回答我的问题。

@zysszy
Copy link
Owner

zysszy commented Feb 7, 2020

如果训练可以继续,那便是可以的~
我这边再查一下bug,谢谢您的关注~
Zeyu

@boyang9602
Copy link

请问关于这个问题有什么进展吗?我也遇到了同样的问题,我觉得是tree的vocabulary有292个,所以embedding取值应该是0-291,但是不知什么原因,代码里某处要给某个矩阵位置赋一个为292的值,所以出现了这个问题。

@boyang9602
Copy link

我的环境是python3.6, tensorflow1.12.0, ubuntu20.04, NLTK3.2.1

@boyang9602
Copy link

您好,我找到问题了,reslove_data.py第87行tree_vocabulary["End"] = len(tree_vocabulary)导致End的值为tree vocabulary的长度(292),超出了取值范围,我注释掉这一行就不会报这个错了。请问这行有什么特殊的用途吗?可以删掉吗?

@zysszy
Copy link
Owner

zysszy commented Jul 23, 2021

您好,我找到问题了,reslove_data.py第87行tree_vocabulary["End"] = len(tree_vocabulary)导致End的值为tree vocabulary的长度(292),超出了取值范围,我注释掉这一行就不会报这个错了。请问这行有什么特殊的用途吗?可以删掉吗?

您好,谢谢您,您这个修改应该是对的 (虽然我不知道我为什么可以训练,但是我看了数据,我觉得您的修改没问题,直接把这行注释了吧,ATIS我看了数据应该需要这一行)。

感谢您的关注~

Zeyu

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

No branches or pull requests

3 participants