MMdetection3d+some parameters appear in more than one parameter group

在使用MMdetection3D时遇到一个困扰已久的bug,错误提示某些参数在多个参数组中出现。尝试过调整数据并行和优化器顺序,但问题依然存在。最终发现是由于在downsample模块中直接引用self.norm3导致的,修改为不直接引用前序模块的写法,解决了这个问题。此问题仅在nn.BatchNorm2d模块中出现,nn.InstanceNorm2d则未受影响。
摘要由CSDN通过智能技术生成

一个卡了我很久的bug,翻遍google跟中文社区都没找到解决方案……有人说数据并行在优化器后面,但MMdetection3D框架顺序规定好了。

初衷就是在模型中插入了一个模块,然后疯狂报这个错,最后定位到了这几行代码上

elif norm_fn == 'batch':
            self.norm1 = nn.BatchNorm2d(planes)
            self.norm2 = nn.BatchNorm2d(planes)
            if not stride == 1:
                self.norm3 = nn.BatchNorm2d(planes)

开始时以为是nn.BatchNorm2d里面的参数引起了优化器底层报错,所以尝试加了

nn.BatchNorm2d(planes, affine=False)

nn.BatchNorm2d(planes,track_running_stats=False)

这样虽然能跑起来不再报错,但是模型的参数少了running_mean跟running_var
最后定位到了后面的代码块:

...
elif norm_fn == 'batch':
            self.norm1 = nn.BatchNorm2d(planes)
            self.norm2 = nn.BatchNorm2d(planes)
            if not stride == 1:
                self.norm3 = nn.BatchNorm2d(planes)
...
self.downsample
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值