问题遇到的现象和发生背景
RuntimeError: Given groups=1, weight of size [16, 64, 3, 3], expected input[32, 512, 38, 38] to have 64 channels, but got 512 channels instead
SSD跑自制数据集,单类,黑白图片
问题相关代码,请勿粘贴截图
def _conv_forward(self, input: Tensor, weight: Tensor, bias: Optional[Tensor]):
if self.padding_mode != 'zeros':
return F.conv2d(F.pad(input, self._reversed_padding_repeated_twice, mode=self.padding_mode),
weight, bias, self.stride,
_pair(0), self.dilation, self.groups)
return F.conv2d(input, weight, bias, self.stride,
self.padding, self.dilation, self.groups)
运行结果及报错内容
File "C:\Users\huayuan001.conda\envs\pyqxr\lib\site-packages\torch\nn\modules\conv.py", line 396, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [16, 64, 3, 3], expected input[16, 512, 38, 38] to have 64 channels, but got 512 channels instead
我的解答思路和尝试过的方法
解决方法1:使用debug找到通道不匹配的地方进行修改
解决方法2:是不是黑白图片通道数和voc数据集彩色图片通道数不一样
我想要达到的结果
解决此错误