How to calculate the number of Parameters
Suppose we have a CNN layer,
input is - 1*1*28*28 (batch_size * channels * height * width )
nn.Conv2d(1, 64, kernel_size=3)
means here input channel is 1 and the ouput channel is 64. the kernel is of size 3 X 3
How to find a number of parameters?
(kernel width * kernel height * number of channel in the previous layer + 1) * Number of filters of the CNN
(3 * 3 * 1 + 1) * 64 = 640 parameters
How to find CNN output size?
[(W-K+2P) / S] + 1
if you have an image of size 1*28*28 where 1 is a channel, 28 is height, and 28 width.
so Input shape = 1*28*28
W- width of an image
K - Kernel size
P - padding
S - Stride
in our case output size is
[(28-3+2*0)/1]+1 = 25
Output shape: 1* 25*25
Comments
Post a Comment