weixin_41897924 2022-03-09 18:46 采纳率: 0%
浏览 137

本地复现陈丹琦的PureNer抽取,加载中文数据集竟然报错?

中文数据集是CMeEE,错误是:Error(s) in loading state_dict for BertForEntity:size mismatch for ner_classifier.1.weight;size mismatch for ner_classifier.1.bias;与这个入口参数有关:max_span_length,这个参数是用来初始化预训练bert的:self.width_embedding = nn.Embedding(max_span_length+1, width_embedding_dim),各位前辈可否给点建议。调试已久,没有思路,即使将max_span_length改成CMeEE的实体类别个数也报同样的错误。具体报错如下:

03/09/2022 18:35:29 - INFO - transformers.modeling_utils - All the weights of BertForEntity were initialized from the model checkpoint at /data/sciERC-bert-model/ent-scib-ctx0/.
If your task is similar to the task the model of the ckeckpoint was trained on, you can already use BertForEntity for predictions without further training.
Traceback (most recent call last):
File "E:\java-workspace\PureTest\wonerMain.py", line 154, in
model = EntityModel(args, num_ner_labels=num_ner_labels)
File "E:\java-workspace\PureTest\wonerModel.py", line 174, in init
self.bert_model = BertForEntity.from_pretrained(bert_model_name, num_ner_labels=num_ner_labels, max_span_length=args.max_span_length)
File "C:\ProgramData\Anaconda3\envs\pytorch37\lib\site-packages\transformers\modeling_utils.py", line 781, in from_pretrained
model.class.name, "\n\t".join(error_msgs)
RuntimeError: Error(s) in loading state_dict for BertForEntity:
size mismatch for ner_classifier.1.weight: copying a param with shape torch.Size([7, 150]) from checkpoint, the shape in current model is torch.Size([10, 150]).
size mismatch for ner_classifier.1.bias: copying a param with shape torch.Size([7]) from checkpoint, the shape in current model is torch.Size([10]).

  • 写回答

2条回答 默认 最新

  • 「已注销」 2022-03-10 08:06
    关注

    不要着急,把报错发过来看一下

    评论

报告相同问题?

问题事件

  • 创建了问题 3月9日

悬赏问题

  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)