Deep Learning · TEE · section
Faculty CNN table: shapes, activations and 62958 parameters
Convolutional neural networks
Question. A CNN receives a 32 × 32 × 3 image. It uses Conv1: eight 5 × 5 filters, stride 1, no padding; Pool1: 2 × 2, stride 2; Conv2: sixteen 5 × 5 filters, stride 1, no padding; Pool2: 2 × 2, stride 2; flatten; dense 120; dense 84; dense 10 followed by softmax. Include one bias per filter or receiving dense neuron. Find every output shape, activation count and trainable-parameter count. (Practice: 10 marks)
Given
Input = 32 × 32 × 3. Both convolutions are ordinary full-channel convolutions. Pooling has no padding. Dense widths are 120, 84 and 10. No batch-normalization layer is present in this particular question.
To find
Output shape and number of output values for each layer, its trainable parameters, and the total parameters.
Formula — which one and why
Use the spatial-size formula for each convolution/pool. Use one full-depth kernel plus one bias per convolutional filter. Flattening counts all remaining values before the first dense layer. Each dense neuron then receives one weight per input plus one bias.
N_{\mathrm{out}}=\left\lfloor\frac{N+2P-K}{S}\right\rfloor+1A=H_{\mathrm{out}}W_{\mathrm{out}}C_{\mathrm{out}}P_{\mathrm{conv}}=(K_hK_wC_{\mathrm{in}}+1)C_{\mathrm{out}}P_{\mathrm{dense}}=(n_{\mathrm{in}}+1)n_{\mathrm{out}}A counts produced activations. P_conv and P_dense count independent learned coefficients. They are not the same quantity. Pooling, flattening and softmax itself add zero learned parameters here.
Solution — step by step
Step 1: input. Shape = 32 × 32 × 3. Values = 32×32×3 = 3,072. Trainable parameters = 0.
Step 2: Conv1 spatial size. (32−5)/1 +1 = 28. Eight filters give shape 28 × 28 × 8. Activations = 28×28×8 = 6,272.
Step 3: Conv1 parameters. One filter contains 5×5×3 = 75 weights. Add one bias: 76. Multiply by eight filters: 76×8 = 608.
Step 4: Pool1. (28−2)/2 +1 = 14. Shape = 14 × 14 × 8. Activations = 14×14×8 = 1,568. Parameters = 0; channel count remains eight.
Step 5: Conv2 spatial size. (14−5)/1 +1 = 10. Sixteen filters give shape 10 × 10 × 16. Activations = 1,600.
Step 6: Conv2 parameters. Its input has eight channels. Each filter has 5×5×8 = 200 weights, then one bias. Total = 201×16 = 3,216.
Step 7: Pool2 and flatten. (10−2)/2 +1 = 5. Pool shape = 5 × 5 × 16. Flattened length = 5×5×16 = 400. Neither operation adds parameters.
Step 8: dense 120. Weights = 400×120 = 48,000. Biases = 120. Parameters = 48,120. Output contains 120 activations.
Step 9: dense 84. Weights = 120×84 = 10,080. Biases = 84. Parameters = 10,164. Output contains 84 activations.
Step 10: dense 10 and softmax. Weights = 84×10 = 840. Biases = 10. Dense parameters = 850. Softmax converts the ten logits into ten probabilities and adds zero parameters. A table naming the combined classifier row “Softmax” attributes these 850 parameters to its preceding dense transformation.
Step 11: add only the trainable counts. 608+3,216 = 3,824; +48,120 = 51,944; +10,164 = 62,108; +850 = 62,958.
| Layer | Output shape | Activations | Parameters |
|---|---|---|---|
| Input | 32 × 32 × 3 | 3,072 | 0 |
| Conv1 | 28 × 28 × 8 | 6,272 | 608 |
| Pool1 | 14 × 14 × 8 | 1,568 | 0 |
| Conv2 | 10 × 10 × 16 | 1,600 | 3,216 |
| Pool2 / flatten | 5 × 5 × 16 / 400 | 400 | 0 |
| Dense 120 | 120 | 120 | 48,120 |
| Dense 84 | 84 | 84 | 10,164 |
| Dense 10 → softmax | 10 | 10 | 850 + 0 |
Final answer: The network has 62,958 trainable parameters. This is the specified classroom CNN, not a universal parameter total for every LeNet-like network.
Yaad rakho: Shape aage carry karo; weights aur activations ko alag columns mein rakho.