Calculating the Number of Parameter in CNN
Consider a simple CNN with the following layers:
- Conv layer: 16 filters, 3×3 size, 3 input channels
- Conv layer: 32 filters, 3×3 size, 16 input channels
- Fully connected layer: 128 input units, 64 output units
- Batch normalization after each convolutional layer
Conv Layer 1:
[Tex]\text{Parameters}=(3×3×3+1)×16=(27+1)×16=448[/Tex]
Batch Norm 1:
[Tex]\text{Parameters}=2×16=32[/Tex]
Conv Layer 2:
[Tex]\text{Parameters}=(3×3×16+1)×32=(144+1)×32=4640[/Tex]
Batch Norm 2:
[Tex]\text{Parameters}=2×32=64[/Tex]
Fully Connected Layer:
[Tex]\text{Parameters}=(128×64)+64=8256[/Tex]
Total Parameters:
[Tex]\text{Total Parameters} = 448 + 32 + 4640 +64 + 8256 = 13440 [/Tex]
So, the total number of parameters in this simple CNN example is 13,440.
How to calculate the number of parameters in CNN?
Calculating the number of parameters in Convolutional Neural Networks (CNNs) is important for understanding the model complexity, computational requirements, and potential overfitting.
Parameters in CNNs are primarily the weights and biases learned during training. This article will walk you through calculating these parameters in various layers of a CNN.
Table of Content
- Steps of Calculate the number of Parameter in CNN
- 1. Convolutional Layer
- 2. Fully Connected (Dense) Layers
- 3. Batch Normalization Layers
- 4. Pooling Layers
- 5. Combining All Layers
- Example: Calculating the Number of Parameter in CNN
- Parameter Calculation for 3D Convolutions
- Factors Affecting Parameter Calculation
- Conclusion