NLPScott/bert-Chinese-classification-task

model.bert.load_state_dict(torch.load(args.init_checkpoint, map_location='cpu'))

longredzhong opened this issue · 7 comments

model.bert.load_state_dict(torch.load(args.init_checkpoint, map_location='cpu'))
RuntimeError: Error(s) in loading state_dict for BertModel:
Missing key(s) in state_dict:
有什么解决办法吗?谢谢!

Originally posted by @wutonghua in #5 (comment)

解决了吗?同样遇到这个问题,不知道怎么解决

遇到同样的问题,同求解决方案

这是加载模型时出的错误,因为转换成pytorch_model.bin用的函数更新了,现在pytorch-pretrained-bert中的convert_tf_checkpoint_to_pytorch.py有变化,可以用下面第193个release时候的函数来生成pytorch_model.bin

地址在这里:

pytorch-pretained-bert with 193 commits

这是加载模型时出的错误,因为转换成pytorch_model.bin用的函数更新了,现在pytorch-pretrained-bert中的convert_tf_checkpoint_to_pytorch.py有变化,可以用第一个release时候的函数来生成pytorch_model.bin

地址在这里:

pytorch-pretained-bert with 193 commits

我一开始就用这个链接中的代码转换的,chinese-base模型,但是还是报这个错了

你好,想问一下 这个问题解决了吗? 现在用更新版本的convert_tf_checkpoint_to_pytorch.py 都还是会出现这样的错误,可以怎么解决呢?

这是加载模型时出的错误,因为转换成pytorch_model.bin用的函数更新了,现在pytorch-pretrained-bert中的convert_tf_checkpoint_to_pytorch.py有变化,可以用下面第193个release时候的函数来生成pytorch_model.bin

地址在这里:

pytorch-pretained-bert with 193 commits

我用193 和最新commit 代码,自己转成pytorch_model.bin,都还是报错,有什么方法吗。谢谢。 @mazicwong