On Convolutions

Say I have a 3x3 kernel for a conv. A normal conv2d would multiply the same 3x3 numbers to all the channels and add them up. What if, say i have 3 channels as input and instead of using the same 3x3 numbers for all the channels, i have different numbers effectively 3(channel) x 3 x 3 (kernel size). How would I do this? Thank you.

The second use case is actually a vanilla convolution and you can check the kernel shape via:

print(nn.Conv2d(3, 1, 3).weight.shape)
> torch.Size([1, 3, 3, 3]) # out_channels, in_channels, height, width

Have a look at CS231n - Convolution layers, which describes the underlying method quite well.

1 Like

Ohhhh. okay thanks. I didn’t know sorry.