PIXELBANKv9.1.0
Menu

Count Parameters in Conv Layer

Problem Statement

Calculate the number of learnable parameters in a Conv2d layer.

Background

A convolutional layer's parameters consist of weights and biases:

  • For KK filters of size F×FF \times F applied to an input with CinC_{in} channels
  • Weight parameters: F×F×Cin×KF \times F \times C_{in} \times K
  • Bias parameters: KK (one per filter)

Your Task

Write a function count_conv_params(filter_size, in_channels, out_channels) returning the total parameter count (weights + biases).

Output Format

Return an integer representing the total number of learnable parameters.

Example:

Input:
filter_size=3, in_channels=1, out_channels=10
Output:
100
Reasoning:

Weights: 3×33 \times 3 × 1×101 \times 10 = 90. Biases: 10. Total: 100.

Constraints:

  • 1 <= filter_size <= 11
  • 1 <= in_channels <= 512
  • 1 <= out_channels <= 512
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.