Parameter Calculation for 3D Convolutions
For a 3D convolutional layer, the number of parameters depends on the size of the filters (kernels), the number of filters, and the number of input channels.
[Tex]\text{Parameters} = (k_d \times k_h \times k_w \times C_{in} + 1) \times C_{out}[/Tex]
Where:
- [Tex]k_d[/Tex]= kernel depth (size along the depth dimension)
- [Tex]k_h[/Tex] = kernel height (size along the height dimension)
- [Tex]k_w[/Tex] = kernel width (size along the width dimension)
- [Tex]C_{in}[/Tex] = number of input channels
- [Tex]C_{out}[/Tex] = number of filters (output channels)
The “+ 1” accounts for the bias term for each filter.
Let’s consider an example for 3D Convolution Neural Network where we will compute the parameters for:
- Conv layer: 16 filters, size 3x3x3, 3 input channels
- Conv layer: 32 filters, size 3x3x3, 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×3+1)×16=82×16=1312[/Tex]
Batch Norm 1:
[Tex]\text{Parameters}=2×16=32[/Tex]
Conv Layer 2:
[Tex]\text{Parameters}=(3×3×3×16+1)×32=(432+1)×32=433×32=13856 [/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} = 1312+32+13856+64+8256=23520[/Tex]
So, the total number of parameters in this simple 3D CNN example is 23,520.
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