Closed KX-Lau closed 1 year ago
使用数据集cner训练bert-bilstm和bert-bilstm-crf模型后,运行predict.py出现以下报错
raceback (most recent call last): File "F:/NER_project/pytorch_bert_bilstm_crf_ner/predict.py", line 120, in print(batch_predict(raw_text, model, device, args, id2query)) File "F:/NER_project/pytorch_bert_bilstm_crf_ner/predict.py", line 39, in batch_predict logits = model(token_ids, attention_masks, token_type_ids, None) File "D:\Envs\easy_bert\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "F:\NER_project\pytorch_bert_bilstm_crf_ner\bert_ner_model.py", line 269, in forward seq_out = seq_out.contiguous().view(batch_size, self.args.max_seq_len, -1) # [batchsize, max_len, num_tags] RuntimeError: shape '[1, 150, -1]' is invalid for input of size 1815
看一下你的参数。
使用数据集cner训练bert-bilstm和bert-bilstm-crf模型后,运行predict.py出现以下报错
raceback (most recent call last): File "F:/NER_project/pytorch_bert_bilstm_crf_ner/predict.py", line 120, in
print(batch_predict(raw_text, model, device, args, id2query))
File "F:/NER_project/pytorch_bert_bilstm_crf_ner/predict.py", line 39, in batch_predict
logits = model(token_ids, attention_masks, token_type_ids, None)
File "D:\Envs\easy_bert\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "F:\NER_project\pytorch_bert_bilstm_crf_ner\bert_ner_model.py", line 269, in forward
seq_out = seq_out.contiguous().view(batch_size, self.args.max_seq_len, -1) # [batchsize, max_len, num_tags]
RuntimeError: shape '[1, 150, -1]' is invalid for input of size 1815