# How many parameters in a Conv2d Layer?

I was following andrew-ng coursera course on deep learning and there's a question that has been asked there which I couldn't figure out the answer for?

Suppose your input is a 300 by 300 color (RGB) image, and you use a convolutional layer with 100 filters that are each 5x5. How many parameters does this hidden layer have (including the bias parameters)?

1. 2501

2. 2600

3. 7500

4. 7600

The right answer is the fourth.

From this, the formula to calculate the number of parameters in a convolutional layer is (nml+1)*k with n = m = 5, k = 100, l = 3 and +1 for the bias.

Based on the equation in the course:

• Weights 5 * 5 * 3 * 100 = 7500
• Bias 100

So total would be 7600.

As we have a RGB Image so our filter changes from 2D to 3D, whose dimension will be 5 * 5 * (no of channels from previous layer) = 5 * 5 * 3 = 75

Now we have 100 such filters, so total parameters increases to = 75 * 100 = 7500

Each filter has a constant bias associated with it, hence this introduces 100 biases for each filter or l00 more features

Total feature required = 5 * 5 * 3 * 100 + 100 = 7600