macanv / BERT-BiLSTM-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning And private Server services
https://github.com/macanv/BERT-BiLSMT-CRF-NER
4.69k stars 1.25k forks source link

训练模型时候报错 #266

Closed zhangjiantong closed 4 years ago

zhangjiantong commented 4 years ago

InvalidArgumentError (see above for traceback): indices[0,1] = 196 is not in [0, 169) [[Node: crf_loss/GatherV2_1 = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](crf_loss/Reshape_3, crf_loss/add_2, crf_loss/GatherV2/axis)]]

macanv commented 4 years ago

错误已经很明显了啊,检查自己的输入输出。

Ailing-Zou commented 4 years ago

您好,想问一下我直接把The Chinese training data($PATH/NERdata/) 里面的examples.train 重命名为 train.txt ,其他的按照您的逻辑也改了,train.txt它的确是以空格分隔,以\n换行的 pd.read_table('train.txt',sep=' ',header=None) 但我的logger.info报错: File "C:\workspace\python\BERT-BiLSTM-CRF-NER\bert_base\train\bert_lstm_ner.py", line 562, in train logger.info(" Num examples = %d", len(train_examples)) TypeError: info() takes 2 positional arguments but 3 were given 请教这是因为什么呢?

macanv commented 4 years ago

@Crystalsudo 你的log.info 写错了啊。。。。。

macanv commented 4 years ago

长时间未回复,我先关了,有问题,再开。

pergrand commented 4 years ago

同样是这个问题用您的模型没问题,但是训练时候会出现这个,找不到,哪地方参数不对。 参数如下:

Traceback (most recent call last): File "D:\sw\anaconda3\envs\tf\Scripts\bert-base-ner-train-script.py", line 11, in load_entry_point('bert-base==0.0.9', 'console_scripts', 'bert-base-ner-train')() File "D:\sw\anaconda3\envs\tf\lib\site-packages\bert_base-0.0.9-py3.6.egg\bert_base\runs__init__.py", line 40, in train_ner train(args=args) File "D:\sw\anaconda3\envs\tf\lib\site-packages\bert_base-0.0.9-py3.6.egg\bert_base\train\bert_lstm_ner.py", line 565, in train logger.info(" 这里? Num examples = %d", len(train_examples)) TypeError: info() takes 2 positional arguments but 3 were given

(tf) D:\test\BERT-BiLSTM-CRF-NER-master>bert-base-ner-train -data_dir D:\test\other\bertNER\data -output_dir D:\test\BERT-BiLSTM-CRF-NER-master\bert_base\output -init_checkpoint C:\Users\Lowe.li\Downloads\chinese_L-12_H-768_A-12 -bert_config_file C:\Users\Lowe.li\Downloads\chinese_L-12_H-768_A-12\bert_config.json -vocab_file C:\Users\Lowe.li\Downloads\chinese_L-12_H-768_A-12\vocab.txt

pergrand commented 4 years ago

长时间未回复,我先关了,有问题,再开。

博主,这个问题有人遇到的吗

WuSiQingChun commented 4 years ago

我也遇到了相同的问题,我查看了一下代码中def info(self, msg, **kwargs): 和我在网上搜到的def info(self, msg, *args, **kwargs):参数量不同,问题应该就是出在这里了。 把logger.info(" Num examples = %d" , len(train_examples))中的逗号,修改成%就可以了。 查看代码中调用info函数的地方修改一下。