RuntimeError: copy_if failed to synchronize: device-side assert triggered

这是我使用的项目地址:https://github.com/amdegroot/ssd.pytorch

问题描述:

这个问题是我在使用SSD做目标检测时遇到的,我要检测的目标有5种类别,所以我在data/config.py中的num_classes参数写了5,经过多方查找,发现了一个没注意到的细节,类别应该是5+1,那个1应该是背景。

还有一个原因就是标签的标号没有从0开始。

 

导入模型时:

RuntimeError: Error(s) in loading state_dict for SSD:
    size mismatch for conf.0.weight: copying a param with shape torch.Size([24, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 512, 3, 3]).
    size mismatch for conf.0.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([20]).
    size mismatch for conf.1.weight: copying a param with shape torch.Size([36, 1024, 3, 3]) from checkpoint, the shape in current model is torch.Size([30, 1024, 3, 3]).
    size mismatch for conf.1.bias: copying a param with shape torch.Size([36]) from checkpoint, the shape in current model is torch.Size([30]).
    size mismatch for conf.2.weight: copying a param with shape torch.Size([36, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([30, 512, 3, 3]).
    size mismatch for conf.2.bias: copying a param with shape torch.Size([36]) from checkpoint, the shape in current model is torch.Size([30]).
    size mismatch for conf.3.weight: copying a param with shape torch.Size([36, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([30, 256, 3, 3]).
    size mismatch for conf.3.bias: copying a param with shape torch.Size([36]) from checkpoint, the shape in current model is torch.Size([30]).
    size mismatch for conf.4.weight: copying a param with shape torch.Size([24, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 256, 3, 3]).
    size mismatch for conf.4.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([20]).
    size mismatch for conf.5.weight: copying a param with shape torch.Size([24, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 256, 3, 3]).
    size mismatch for conf.5.bias: copying a param with shape torch.Size([24]) from checkpoint, the shape in current model is torch.Size([20]).

原因同样是类别导致,训练时写了多少类就应该是多少(包括背景)

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 38
    评论
评论 38
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

如雾如电

随缘

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值