侧边栏壁纸
博主头像
小鱼吃猫博客博主等级

你所热爱的,便是你的生活。

  • 累计撰写 100 篇文章
  • 累计创建 44 个标签
  • 累计收到 7 条评论

目 录CONTENT

文章目录

ValueError: too many dimensions 'str'

小鱼吃猫
2023-08-04 / 0 评论 / 0 点赞 / 14 阅读 / 748 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2023-08-04,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

ValueError: too many dimensions 'str'

使用Bert进行训练时,报错如题。具体如下:

ValueError: too many dimensions 'str'

The above exception was the direct cause of the following exception:

ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length. Perhaps your features (`labels` in this case) have excessive nesting (inputs type `list` where type `int` is expected).

解决方案

labels应该是str 类型的,改成int即可

labels=[int(label) for label in labels]
0

评论区