Understanding Feature Maps in Convolutional Layers (PyTorch)
I've got this segment of code in a discriminator network for MNIST:

nn.Conv2d(1, 64, 4, 2, 1),


From my understanding, there is 1 input channel (the MNIST image), then we apply a 4x4 kernel to the image in strides of 2 to produce 64 feature maps. Does this mean that we actually have 64 kernels at this layer? Because in order to get 64 different feature maps, we would need 64 separate kernels to convolve over the image?

Then after some ReLu, we have another convolution:

nn.Conv2d(64, 128, 4, 2, 1),


How do we get from 64 to 128? From my understanding of the first example, we have 64 seperate kernels that can produce 64 seperate feature maps. But here we go from 64 feature maps to 128 feature maps? Does that mean that we only have two kernels?

I hope someone can shine some light on whether my understanding is correct!

Your understanding in the first example is correct, you have 64 different kernels to produce 64 different feature maps.

In case of the second example, so the number of input channels not beeing one, you still have as "many" kernels as the number of output feature maps (so 128), which each are trained on a linear combination of the input feature maps. So in your case each of these kernels would have 4x4x64 trainable weights.
