shiyybua / NER

基于tensorflow深度学习的中文的命名实体识别
1.04k stars 400 forks source link

预测完全错误的问题 #27

Open wangqingbin opened 6 years ago

wangqingbin commented 6 years ago

我在训练时程序运行正常,但是在预测的过程中出现以下错误

building word index... source vocabulary file has already existed, continue to next stage. target vocabulary file has already existed, continue to next stage. loading word embedding, it will take few minutes... 2018-04-14 08:29:30.012808: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 D:\ProgramData\Miniconda3\envs\tensorflow35\lib\site-packages\tensorflow\python\ops\gradients_impl.py:96: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory. "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "

loading pre-trained model from resource/model/points-10000..... ['新华社', '北京', '9', '月', '11', '日电', '第二十二届', '国际', '检察官', '联合会', '年会', '暨', '会员', '代表大会', '11', '日', '上午', '在', '北京', '开幕', '。', '国家', '主席', '习近平', '发来', '贺信', ',', '对', '会议', '召开', '表示祝贺', '。'] [b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'O', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b''] 32 33 Traceback (most recent call last): File "E:/NER-master/rnn.py", line 180, in predict(net, tag_table, sess) File "E:/NER-master/rnn.py", line 140, in predict write_result_to_file(file_iter, tags) File "E:\NER-master\utils.py", line 297, in write_result_to_file assert len(words) == len(tags) AssertionError

发现预测的结果不是O就是unknown,而且也报了长度不一致的错误,请问这种情况应该怎样解决。

FranksZhang commented 6 years ago

您好,我也遇到这个问题了,不知道你是否已经解决了?是怎么解决的呢?

wangqingbin commented 6 years ago

这个是字符编码的问题,一定要确保你的所有的文件都是用utf-8(无BOM)来编码,出现这个问题就是字符编码的问题

chxt6896 commented 6 years ago

新华社 (B-ORG) 北京 (B-ORG) 9 (I-ORG) 月 (I-ORG) 11 (O) 日电 (O)   (O) 第二十二届 (O) 国际 (O) 检察官 (O) 联合会 (O) 年会 (O) 暨 (O) 会员 (B-TIME) 代表大会 (I-TIME) 11 (I-TIME) 日 (O) 上午 (O) 在 (O) 北京 (B-LOC) 开幕 (O) 。 (O) 国家 (B-ORG) 主席 (I-ORG) 习近平 (O) 发来 (O) 贺信 (O) , (O) 对 (O) 会议 (O) 召开 (O) 表示祝贺 (O) 。 (O)

虽然不全是O,但也感觉大部分是O