bert.embeddings.word_embeddings的尺寸不匹配。

发布于 2025-02-01 17:59:09 字数 943 浏览 4 评论 0原文

RuntimeError:bertforrelationExtraction的加载state_dict中的错误: bert.embeddings.word_embeddings的尺寸不匹配。

Traceback (most recent call last):
  File "main.py", line 248, in <module>
    result = trainer.predict(tokenizer, text, id2label, args, ids)
  File "main.py", line 146, in predict
    model, optimizer, epoch, loss = self.load_ckp(model, optimizer, checkpoint)
  File "main.py", line 38, in load_ckp
    model.load_state_dict(checkpoint['state_dict'])
  File "C:\Anaconda3\envs\NLP_Research\lib\site-packages\torch\nn\modules\module.py", line 1045, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for BertForRelationExtraction:
        size mismatch for bert.embeddings.word_embeddings.weight: copying a param with shape torch.Size([21128, 768]) from checkpoint, the shape in current model is torch.Size([30522, 768]).  

RuntimeError: Error(s) in loading state_dict for BertForRelationExtraction:
size mismatch for bert.embeddings.word_embeddings.weight: copying a param with shape torch.Size([21128, 768]) from checkpoint, the shape in current model is torch.Size([30522, 768])

Traceback (most recent call last):
  File "main.py", line 248, in <module>
    result = trainer.predict(tokenizer, text, id2label, args, ids)
  File "main.py", line 146, in predict
    model, optimizer, epoch, loss = self.load_ckp(model, optimizer, checkpoint)
  File "main.py", line 38, in load_ckp
    model.load_state_dict(checkpoint['state_dict'])
  File "C:\Anaconda3\envs\NLP_Research\lib\site-packages\torch\nn\modules\module.py", line 1045, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for BertForRelationExtraction:
        size mismatch for bert.embeddings.word_embeddings.weight: copying a param with shape torch.Size([21128, 768]) from checkpoint, the shape in current model is torch.Size([30522, 768]).  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文