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

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

  • 累计撰写 114 篇文章
  • 累计创建 47 个标签
  • 累计收到 9 条评论

目 录CONTENT

文章目录

ValueError: too many dimensions 'str'

小鱼吃猫
2023-08-04 / 0 评论 / 0 点赞 / 95 阅读 / 732 字

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

评论区