Parameter Count in Convolutional Layers
What You'll Learn
You'll learn how to calculate exactly how many learnable parameters (weights and biases) exist in a convolutional layer.
Why This Matters
Understanding parameter count helps you grasp model complexity, memory requirements, and why CNNs are so efficient compared to fully-connected layers. It's essential for designing and debugging architectures.
The Formula
For a convolutional layer, the number of parameters depends on:
- Kernel size (height × width)
- Input channels (depth of input)
- Output channels (number of filters)
- Bias terms (one per output channel)
Formula:
Parameters = (kernel_height × kernel_width × input_channels × output_channels) + output_channels
The first part counts all weights in all kernels. The second part (+ output_channels) adds one bias per filter.
Concrete Example
Imagine a convolutional layer with:
- Kernel size: 3×3
- Input channels: 64 (e.g., from previous layer)
- Output channels: 128 (number of filters in this layer)
Calculation:
- Weights: 3 × 3 × 64 × 128 = 73,728
- Biases: 128
- Total: 73,856 parameters
Each of the 128 filters has its own 3×3×64 kernel plus one bias.
Why CNNs Are Efficient
Compare this to a fully-connected layer connecting 64×32×32 inputs (65,536 values) to 128 outputs: that would require 65,536 × 128 = 8,388,608 parameters! Convolution achieves spatial processing with far fewer parameters through weight sharing—the same kernel slides across the entire input.
Key Takeaway: The parameter count in a convolutional layer equals (kernel dimensions × input channels × output channels) plus biases, making CNNs vastly more parameter-efficient than dense layers for spatial data.