An error occurred while I was trying to train the VOC2007 data set:
RuntimeError:Given groups=1, weight of size 256 304 3 3,expected input[1,2096,129,129]to have 304 channels, but got 2096 channels instead.
The error code is:
class Decoder(nn.Module):
def init(self, num_classes, backbone, BatchNorm):
super(Decoder, self).init()
if backbone == ‘resnet’ or backbone == ‘drn’:
low_level_inplanes = 256
elif backbone == ‘xception’:
low_level_inplanes = 128
elif backbone == ‘mobilenet’:
low_level_inplanes = 24
else:
raise NotImplementedError
self.conv1 = nn.Conv2d(low_level_inplanes, 48, 1, bias=False)
self.bn1 = BatchNorm(48)
self.relu = nn.ReLU()
self.last_conv = nn.Sequential(nn.Conv2d(304, 256, kernel_size=3, stride=1, padding=1, bias=False),
BatchNorm(256),
nn.ReLU(),
nn.Dropout(0.5),
nn.Conv2d(256, 256, kernel_size=3, stride=1, padding=1, bias=False),
BatchNorm(256),
nn.ReLU(),
nn.Dropout(0.1),
nn.Conv2d(256, num_classes, kernel_size=1, stride=1))
self._init_weight()
def forward(self, x, low_level_feat):
    low_level_feat = self.conv1(low_level_feat)
    low_level_feat = self.bn1(low_level_feat)
    low_level_feat = self.relu(low_level_feat)
    x = F.interpolate(x, size=low_level_feat.size()[2:], mode='bilinear', align_corners=True)
    x = torch.cat((x, low_level_feat), dim=1)
    x = self.last_conv(x)

    return x

VOC data set is a 3-channel image, I used it to train deeplab v3plus network, 23 lines of the above code are written into the input channel bit 304, how should I calculate the channel number of the input 3-channel image without a convolution or other layer training? According to the error, directly modify 304 to 2096? Hope to get the answer, thank you very much