Arturas_Druteika:

To my understanding normal convolutional operation has as many unique kernels per filter as there are input channels.


“Kernels” and “filters” are used interchangeable and refer to the same object. If you refer to “kernel” as a 2D kernel, which is stacked into a “filter”, then you are right, but note that this description is not commonly used in the deep learning area.



 Arturas_Druteika:

As I understand if groups=in_channels, then one filter has only one unique kernel, for example let’s make that one kernel and fill it with values all equal to 1 with kernel size 3x3. So the same kernel would be used on all the input channels (for example channel R, channel G, channel B).


No, if groups=in_channels, each filter will be used for a separate input channel. The Guide to Convolution Arithmetic 1 gives examples and visualizes it in a beautiful way. Here is additionally a code snippet you could play around to check how the kernels are applied:
conv = nn.Conv2d(3, 3, 3, 1, 1, bias=False, groups=3)
print(conv.weight.shape)

with torch.no_grad():
    conv.weight = nn.Parameter(
        torch.stack((
            torch.ones(1, 3, 3),
            torch.ones(1, 3, 3) * 2,
            torch.ones(1, 3, 3) * 3
        ))
    )

x = torch.cat((
    torch.ones(1, 3, 3),
    torch.ones(1, 3, 3) * 2,
    torch.ones(1, 3, 3) * 3
), dim=0).unsqueeze(0)
print(x.shape)

out = conv(x)
print(out.shape)

print(out)




 Arturas_Druteika:

What I don’t understand is why depthwise seperable convolution uses only one kernel per filter if groups=in_channels? Does’t the fact that the same kernel for all channels make the model lose a little bit of information or is that a whole point of depthwise seperable convolution aside from the fact that it drastically reduces the computational cost?


I think the idea was introduces in the Xception paper and the authors might explain their ideas in this paper.