首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >The shape of the mask [32, 8732] at index 0

The shape of the mask [32, 8732] at index 0

作者头像
狼啸风云
修改2022-09-02 20:22:39
修改2022-09-02 20:22:39
2.3K00
代码可运行
举报
运行总次数:0
代码可运行

IndexError: The shape of the mask [32, 8732] at index 0does not match the shape of the indexed tensor [279424, 1] at index 0

如果出现类似于以上的索引错误,需要将layers/modules/multibox_loss.py 的代码按照下图修改即可。注释掉的是源代码,下面的是新加的,即交换两行代码的顺序即可。

解决了这个问题,又会出现一个新问题:

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

解决方法:将错误行的 .data[0] 修改为 .item() 即可

代码语言:javascript
代码运行次数:0
运行
复制
 # loc_loss += loss_l.data[0]
 # conf_loss += loss_c.data[0]

loc_loss += loss_l.item()
conf_loss += loss_c.item()
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/12/17 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档