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

train error #6

Closed
754807266 opened this issue Nov 29, 2018 · 4 comments
Closed

train error #6

754807266 opened this issue Nov 29, 2018 · 4 comments

Comments

@754807266
Copy link

train len: 36064
test len: 5010
word2id len 4026
Creating the data generator ...
Finished creating the data generator.
begin to train...
Traceback (most recent call last):
File "train.py", line 108, in
model = Model(config,embedding_pre,dropout_keep=0.5)
File "/home/homework/proj/tensorflow/ChineseNER-master/tensorflow/bilstm_crf.py", line 20, in init
self._build_net()
File "/home/homework/proj/tensorflow/ChineseNER-master/tensorflow/bilstm_crf.py", line 57, in _build_net
self.viterbi_sequence, viterbi_score = tf.contrib.crf.crf_decode(bilstm_out, self.transition_params,tf.tile(np.array([self.sen_len]),np.array([self.batch_size])))
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/crf/python/ops/crf.py", line 537, in crf_decode
false_fn=_multi_seq_fn)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/layers/utils.py", line 206, in smart_cond
pred, true_fn=true_fn, false_fn=false_fn, name=name)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/smart_cond.py", line 56, in smart_cond
return false_fn()
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/crf/python/ops/crf.py", line 501, in _multi_seq_fn
sequence_length_less_one = math_ops.maximum(0, sequence_length - 1)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 4602, in maximum
"Maximum", x=x, y=y, name=name)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Maximum' Op has type int64 that does not match type int32 of argument 'x'.

谷歌也没搜出来解决办法,应该在哪加一个数据类型转换?

@buppt
Copy link
Owner

buppt commented Dec 1, 2018

train len: 36064
test len: 5010
word2id len 4026
Creating the data generator ...
Finished creating the data generator.
begin to train...
Traceback (most recent call last):
File "train.py", line 108, in
model = Model(config,embedding_pre,dropout_keep=0.5)
File "/home/homework/proj/tensorflow/ChineseNER-master/tensorflow/bilstm_crf.py", line 20, in init
self._build_net()
File "/home/homework/proj/tensorflow/ChineseNER-master/tensorflow/bilstm_crf.py", line 57, in _build_net
self.viterbi_sequence, viterbi_score = tf.contrib.crf.crf_decode(bilstm_out, self.transition_params,tf.tile(np.array([self.sen_len]),np.array([self.batch_size])))
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/crf/python/ops/crf.py", line 537, in crf_decode
false_fn=_multi_seq_fn)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/layers/utils.py", line 206, in smart_cond
pred, true_fn=true_fn, false_fn=false_fn, name=name)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/smart_cond.py", line 56, in smart_cond
return false_fn()
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/crf/python/ops/crf.py", line 501, in _multi_seq_fn
sequence_length_less_one = math_ops.maximum(0, sequence_length - 1)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 4602, in maximum
"Maximum", x=x, y=y, name=name)
File "/home/homework/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Maximum' Op has type int64 that does not match type int32 of argument 'x'.

谷歌也没搜出来解决办法,应该在哪加一个数据类型转换?

应该是你输入训练的y是int64类型的,模型里的placeholder设置的是int32,你改一个,统一一下就行了。

@buppt buppt closed this as completed Dec 5, 2018
@Foehnc
Copy link

Foehnc commented Dec 20, 2018

请问能详细说一下怎么改吗 遇到了同样的问题

@bobkentt
Copy link

我也遇到了同样的问题

@bobkentt
Copy link

请问能详细说一下怎么改吗 遇到了同样的问题

你最后怎么改好的啊

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

4 participants