DeepLabV3 layers size

Hey everyone,

I tried to use DeepLabV3+ head for segmentation, as a part of a new architecture model, and I couldn’t train it. while debugging I found out that there is an problem that seems to be inherent in this head class.

the head contains 4 ASSPconv classes, and one ASSPpool classes. the last one contains the following layers:

class ASPPPooling(nn.Sequential):
    def __init__(self, in_channels, out_channels):
        super(ASPPPooling, self).__init__(
            nn.Conv2d(in_channels, out_channels, 1, bias=False),

    def forward(self, x):
        size = x.shape[-2:]
        for mod in self:
            x = mod(x)
        return F.interpolate(x, size=size, mode='bilinear', align_corners=False)

the bug is hiding in the BN layer, which couldn’t get 1*1 shape tensor in “train mode”. but the first AdaptiveAvgPool2d layer is forcing that shape.

I appologize about the weak English,
and I would aprritiate your help!


I don’t think this is necessarily an error, but might be a design decision.
E.g. the inception_v3 model also doesn’t accept single samples in train() mode for the same reason and fails in a batchnorm layer as seen here:

# setup
model = models.inception_v3(init_weights=False)

x = torch.randn(1, 3, 299, 299)
out = model(x) # error in batchnorm layer
> ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 768, 1, 1])

x = torch.randn(2, 3, 299, 299)
out = model(x) # works