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

模型初始化的时候出错,请教一下原因 #7

Open
cglirang opened this issue Nov 24, 2016 · 1 comment
Open

模型初始化的时候出错,请教一下原因 #7

cglirang opened this issue Nov 24, 2016 · 1 comment

Comments

@cglirang
Copy link

参数全部默认

训练数据:
放 推荐动词_S
一 O_S
首 O_S
我 歌曲名_B
们 歌曲名_M
的 歌曲名_M
世 歌曲名_M
代 歌曲名_E
。 O_S

适 O_B
合 O_E
老 其他实体_B
人 其他实体_E
的 O_S
爱 歌曲名_B
情 歌曲名_M
的 歌曲名_M
结 歌曲名_M
束 歌曲名_E
。 O_S

具体错误:
File "train.py", line 47, in <module> model = BILSTM_CRF(num_chars=num_chars, num_classes=num_classes, num_steps=num_steps, num_epochs=num_epochs, embedding_matrix=embedding_matrix, is_training=True) File "/home/lirang/workspace/sequence-labeling/code/bilstm_crf/BILSTM_CRF.py", line 103, in __init__ self.total_path_score, self.max_scores, self.max_scores_pre = self.forward(self.observations, self.transitions, self.length) File "/home/lirang/workspace/sequence-labeling/code/bilstm_crf/BILSTM_CRF.py", line 121, in forward transitions = tf.reshape(tf.concat(0, [transitions] * self.batch_size), [self.batch_size, 6, 6]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1092, in reshape name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2156, in create_op set_shapes_for_outputs(ret) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1612, in set_shapes_for_outputs shapes = shape_func(op) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1115, in _ReshapeShape % (num_elements.value, new_shape, np.prod(new_shape))) ValueError: Cannot reshape a tensor with 512 elements to shape [128, 6, 6] (4608 elements)

@chilynn
Copy link
Owner

chilynn commented Nov 24, 2016

你好,目前这个版本只能支持BMEO这4种label,[self.batch_size, 6, 6],这里的6是在头和尾各加了一个标识,即6 = 4+1+1。
请把:歌曲名_B 改为 B
如果需要识别歌曲名,可以单独标识歌曲名,其他的都是O
如果需要识别多种类型的实体,请训练多个模型
谢谢你的反馈^_^,我会在下个版本中考虑label的多样性

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

2 participants