mmdetection-报错RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)

我在使用mmdetection修改neck.fpn的时候,遇到了以下报错:

1、RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same, but I set model and data to cuda

2、NotImplementedError

网上很多建议第1个报错将网络和模型都部署到GPU,但是我的问题不在这,后来经过一番检索(StackOverflow网友建议)发现,应该是nn.ModuleList与nn.Sequential的使用问题,mmdetetion中,可能是由于注册方式的原因(具体原因没有深入了解),在修改网络的时候,需要尽量避免使用nn.Sequential,应当优先使用nn.ModuleList。同时使用nn.ModuleList后,需要在forward中实现,具体差别和使用方法可参考文章——详解PyTorch中的ModuleList和Sequential,nn.ModuleList实现如下,我直接复制过来


                
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值