当前位置: 首页> 财经> 访谈 > 在线ps_品牌建设论文怎么写_seo是什么岗位_seo搜索引擎优化是什么

在线ps_品牌建设论文怎么写_seo是什么岗位_seo搜索引擎优化是什么

时间:2025/7/11 3:56:53来源:https://blog.csdn.net/qq_40515156/article/details/146149631 浏览次数:1次
在线ps_品牌建设论文怎么写_seo是什么岗位_seo搜索引擎优化是什么

在复现一个项目时,原项目使用的是英文词汇表,换成中文的bert模型之后报错:untimeError: Error(s) in loading state_dict for BertForMaskedLM:
        size mismatch for bert.embeddings.word_embeddings.weight: copying a param with shape torch.Size([30522, 768]) from checkpoint, the shape in current model is torch.Size([21128, 768]).
        size mismatch for cls.predictions.bias: copying a param with shape torch.Size([30522]) from checkpoint, the shape in current model is torch.Size([21128]).
        size mismatch for cls.predictions.decoder.weight: copying a param with shape torch.Size([30522, 768]) from checkpoint, the shape in current model is torch.Size([21128, 768]).
        size mismatch for cls.predictions.decoder.bias: copying a param with shape torch.Size([30522]) from checkpoint, the shape in current model is torch.Size([21128]).

根据错误提示可以看到就是vocab_size不一致。 

解决方案:

第一步:打开本地模型路径下的config.jason文件,将里面的"vocab_size"改为30522。改完之后报错如下:

第二步:根据错误提示,在from_pretrained方法中加入ignore_mismatched_sizes=True

重新运行程序,能跑了!!!

关键字:在线ps_品牌建设论文怎么写_seo是什么岗位_seo搜索引擎优化是什么

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: