# Output size and parameter count are different

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/7/tee-c7-s12

Canonical: https://deep-learning-study-room.vercel.app/read/dl/tee/section/tee-c7-s12/

**Definition.** Output shape specifies the size of a layer's computed tensor. Parameter count specifies the number of independent trainable coefficients. Spatial weight sharing allows a convolutional layer to produce many activations from comparatively few parameters.

### Explanation and working

**Question.** A 7 × 7 × 3 input passes through two 3 × 3 filters, stride 2 and padding 1. Find output shape and parameter count, including bias.

### Given

Input = 7 × 7 × 3; two 3 × 3 filters.

Stride = 2; padding = 1; include biases.

### To find

Find the output shape and trainable parameter count.

### Formula — which one and why

**Convolution/pooling spatial size.** Padding adds P positions at both ends. Subtract kernel width to find the last valid start, divide by stride, take the floor and include the initial placement with +1.

N = current height or width; K = kernel/window size; S = stride; P = padding per side. Apply separately to height and width; dilation is 1 here.



$$
N_{\mathrm{out}}=\left\lfloor\frac{N+2P-K}{S}\right\rfloor+1
$$



**Yaad rakhne ka cue:** Input + dono sides ki padding − kernel; stride se divide; floor + 1.

**Convolution parameters.** Every filter spans all input channels. Count its spatial coefficients across those channels, add one bias and multiply by the number of filters.

K\_h,K\_w = filter height/width; C\_in = input channels; C\_out = number of filters and output channels. Spatial output positions reuse these weights.



$$
N_w=K_hK_wC_{\mathrm{in}}C_{\mathrm{out}}
$$





$$
N_b=C_{\mathrm{out}}
$$





$$
P=N_w+N_b
$$



**Yaad rakhne ka cue:** Filter area × input channels × filters; phir ek bias per filter.

### Solution — step by step

**Step 1 spatial size:** padding adds two, giving 7 + 2 − 3 = 6. Divide by stride: 6 ÷ 2 = 3. Apply floor and add the first position: 3 + 1 = 4. There are two filters, so output is 4 × 4 × 2.

![Output size counts produced values; parameter count counts adjustable weights and biases.](https://deep-learning-study-room.vercel.app/assets/figures/v_parameters_activations.svg)

Diagram: Output size counts produced values; parameter count counts adjustable weights and biases.. Labels: Learned parameters are not output activations | Learned parameters are not output activations | Example: a 5 × 5 × 1 input with one 3 × 3 filter, stride 1, no padding. | Learned filter | 3 × 3 × 1 = 9 weights | Plus one bias | Total parameters = 10 | Output feature map | (5 − 3)/1 + 1 = 3 | Shape = 3 × 3 × 1 | Total activations = 9 | The same ten parameters are reused to calculate all nine output values.

Output size counts produced values; parameter count counts adjustable weights and biases. Tap the diagram to enlarge.

**Step 2 parameters:** one filter has 3 × 3 × 3 = 27 weights and one bias, giving 28. Two filters have 56 parameters. The 4 × 4 output positions reuse those weights; they do not create 16 new sets of parameters.
