zhaogaofeng611 / TextMatch

基于Pytorch的,中文语义相似度匹配模型(ABCNN、Albert、Bert、BIMPM、DecomposableAttention、DistilBert、ESIM、RE2、Roberta、SiaGRU、XlNet)
787 stars 146 forks source link

下载回来模型和data 跑test 的时候报错 #5

Open huwei1024 opened 4 years ago

huwei1024 commented 4 years ago

Traceback (most recent call last): File ".\test.py", line 51, in main("d:\test.csv", "models/best.pth.tar") File ".\test.py", line 43, in main model.load_state_dict(checkpoint["model"]) File "C:\Python\Python38\lib\site-packages\torch\nn\modules\module.py", line 1044, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for BertModelTest: Missing key(s) in state_dict: "bert.bert.embeddings.position_ids".

如何解决?

ruthy-wei commented 3 years ago

你解决了嘛?跟你遇到同意的问题..

monkdou0 commented 3 years ago

same question

yh7109 commented 3 years ago

加一个False就好了 model.load_state_dict(checkpoint["model"], False)