Closed wxr666666 closed 1 year ago
作者您好 在用高版本torch运行您的代码时出现了和楼上一样的错误 在第89轮训练报错 ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part. 更换低版本后 并修改这句代码后attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'])).long().unsqueeze(0).to(device) 还是会出现 大佬可以指点一下吗 谢谢!
你predict里面代码是这样的吗:
try:
attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'], dtype=np.uint8)).unsqueeze(0).to(device)
except Exception as e:
attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'])).long().unsqueeze(0).to(device)
作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答
作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答
方便发下你的torch和transformers版本么
作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答
改下这个试试:
token_ids = torch.from_numpy(np.array(encode_dict['input_ids'])).long().unsqueeze(0).to(device)
谢谢大佬,好了!
已经好了,太感谢啦!
@.*** | |
---|---|
@.*** |
---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年03月13日 18:34 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [taishan1994/pytorch_bert_bilstm_crf_ner] 运行问题 (Issue #38) |
作者您好,问题同上,更改你刚才给出的代码依然报错,请问哪里出问题了,烦请解答
方便发下你的torch和transformers版本么
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
作者您好 在用高版本torch运行您的代码时出现了和楼上一样的错误 在第89轮训练报错 ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part. 更换低版本后 并修改这句代码后attention_masks = torch.from_numpy(np.array(encode_dict['attention_mask'])).long().unsqueeze(0).to(device) 还是会出现 大佬可以指点一下吗 谢谢!