Applying 2D Convolution

As far as I understand this function applies one feature map to every image in mini batch ? How can I apply, for example, 5 feature maps for one image, with feature maps having their own sets of shared weights and biases ?

It’s just a regular convolution function (i.e., the default convolution operation that is used in typical convnets on 2d images). So, yes, you will use one kernel to generate the feature maps for every image in a mini batch. Basically, you will get one feature map per kernel. Hence, if you want 5 feature maps for one image, you need 5 kernels. Here’s an illustration:

If you look at the function definition of the function:

torch.nn.functional.conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) → Tensor

the kernels are called weight here and have the dimensions

08%20PM

Hence, you can simply provide a tensor with 5 out_channels

3 Likes

Now I got it right ! Thank you so much for your help !

Glad to hear that it helped!

1 Like