记20200923Pytorch版SSD训练自己数据所遇错误

在此先感谢Windows下自己训练数据集,在pytorch上实现基于SSD的物体检测一文作者,根据此文得以顺利实现目标检测;
在根据此文进行调试之后,在训练过程中遇到两个错误:

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

张量不匹配
应该是layers/modules/multibox_loss中97与98行处loss_c与它的索引pos大小不同引起,将两行互换
在这里插入图片描述

  1. div_(): argument ‘other’ (position 1) must be Tensor, not builtin_function_or_method
div_(): argument 'other' (position 1) must be Tensor, not builtin_function_or_method

解决方法是将layers/modules/multibox_loss最后改为

        N = num_pos.data.sum()
        N = N.type(torch.cuda.FloatTensor)
        # loss_l = loss_l.double()
        # loss_c = loss_c.double()
        loss_l /= N
        loss_c /= N
        return loss_l, loss_c

感谢ssd.pytorch源码迁移实现(pytorch版本从0.2迁移到0.4(1.0))作者提出的解决方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值