How can I calculate the number of parameters for a 2D CNN layer?

I usually use the equation: output width= ((W-F+2*P )/S)+1 = (x)

The same answer will be valid for the output height considering that they have the same dimension. So the output dimension will be (x,x).

However, what if I want to calculate the number of parameters for a 2D CNN layer with filter size 5x5, input channel/depth = 3, and output channel or depth of 8?

  • $\begingroup$ What are W, F, P, S and x? $\endgroup$ – timleathart May 10 '19 at 2:48

When we say the filter size if 5x5 it is for an image with 1 input channel, for three the filter size is 5x5x3 (but at a lot of places this additional info is skipped to make things easy to understand). When you apply a kernel of 5x5x3 to an image the output is just one channel. To get an output of 8 channels you need 8 such kernels. In that case, the number of parameters would be 5x5x3x8.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.