Deep Learning · TEE · section

Faculty Assignment2 Q3 · 28×28 CNN

Faculty Assignment 2 · worked practice

Question

Question. Input28×28×1; conv5,6valid; pool2stride2; conv5,16valid; pool2stride2; dense120,dense84,dense10. Find layer dimensions and parameters. (Faculty assignment: no marks printed)

Answer — step by step

Given

Input=[28, 28, 1]

LayerKernelStridePaddingFilters / units
Conv5106
Pool2200
Conv51016
Pool2200
Dense000120
Dense00084
Dense00010

To find

Each output shape and all trainable weights plus biases.

Formula: which one and why

O=\left\lfloor\frac{N+2P-F}{S}\right\rfloor+1LaTeX: O=\left\lfloor\frac{N+2P-F}{S}\right\rfloor+1
P_{conv}=(F_hF_wC_{in}+1)C_{out},\quad P_{dense}=(n_{in}+1)n_{out}LaTeX: P_{conv}=(F_hF_wC_{in}+1)C_{out},\quad P_{dense}=(n_{in}+1)n_{out}

Each filter/unit has one bias. Pooling has zero learned parameters. Flatten preserves the number of values, then a dense layer connects every input value to every output unit.

Step 1. Work layer by layer

LayerInputFull substitution and reasonOutputParameters
Conv28×28×1⌊(28+2×0−5)/1⌋+1=24; parameters=(5×5×1+1)×6=15624×24×6156
Pool24×24×6⌊(24−2)/2⌋+1=12; channels stay 6; no trainable weights12×12×60
Conv12×12×6⌊(12+2×0−5)/1⌋+1=8; parameters=(5×5×6+1)×16=24168×8×162416
Pool8×8×16⌊(8−2)/2⌋+1=4; channels stay 16; no trainable weights4×4×160
Dense4×4×16Flatten/input length=4×4×16=256; parameters=(256+1)×120=3084012030840
Dense1×1×120Flatten/input length=1×1×120=120; parameters=(120+1)×84=101648410164
Dense1×1×84Flatten/input length=1×1×84=84; parameters=(84+1)×10=85010850

Step 2. Sum only trainable parameters

156 + 2416 + 30840 + 10164 + 850 = 44426

Final answer

Total parameters=44426. Shape and parameter count are separate results.