Deep Learning · TEE · section
F23 Q1d
Final examination December 2023 fully solved
Question
Question (5 marks). Compute the convolution using the input A and kernel K shown below using padding 0 and stride 1.
| 10 | 9 | 5 | 6 |
| 5 | 7 | 6 | 7 |
| 3 | 3 | 2 | 8 |
| 3 | 2 | 6 | 7 |
| 1 | 1 | 1 |
| 1 | 2 | 1 |
| 1 | 1 | 1 |
Stride 1; P = 0 (no padding).
Answer — step by step
Given
Compute the convolution using the input A and kernel K shown below using padding 0 and stride 1.
To find
Find every convolution output cell.
Formula — which one and why
Convolution values. At each valid location, multiply corresponding window and kernel entries, add all products and add the filter bias once. Move by the stated stride and repeat.
X = input; K = kernel; S = stride; b = filter bias; u,v locate a kernel entry. Use the printed kernel without flipping under the stated deep-learning convention.
Y_{ij}=\sum_{u,v}X_{iS+u,jS+v}K_{uv}+bYaad rakhne ka cue: Matching cells multiply; sab products add; bias sirf ek baar.
Solution — step by step
Follow each selected input window below. Matching row colors connect its input cells, kernel coefficients and products; the outlined output cell shows where their sum belongs.
Step 1 shape: LaTeX:
\left\lfloor\frac{4+2 \times 0-3}{1}\right\rfloor+1 = 2 along each axis. Use the deep-learning cross-correlation convention: do not flip the printed kernel.
Output position (1, 1)
Use this position's input window. Multiply corresponding entries row by row; then add all row totals.
Input rows 1–3, columns 1–3. The window moves 1 cell per output step.
| 10 | 9 | 5 | 6 |
| 5 | 7 | 6 | 7 |
| 3 | 3 | 2 | 8 |
| 3 | 2 | 6 | 7 |
Only the outlined cells belong to this output.
| 1 | 1 | 1 |
| 1 | 2 | 1 |
| 1 | 1 | 1 |
Same row and column positions; no matrix multiplication.
| 10 | 9 | 5 |
| 5 | 14 | 6 |
| 3 | 3 | 2 |
Each cell is input × matching kernel coefficient.
24 + 25 + 8 = 57
| 57 | 59 |
| 40 | 50 |
Output row 1, column 1.
Window row 1.
R_1=(10)\times(1)+(9)\times(1)+(5)\times(1)=24Window row 2.
R_2=(5)\times(1)+(7)\times(2)+(6)\times(1)=25Window row 3.
R_3=(3)\times(1)+(3)\times(1)+(2)\times(1)=8Add the rows to obtain one output cell.
Y_{1,1}=(24)+(25)+(8)=57Output position (1, 2)
Use this position's input window. Multiply corresponding entries row by row; then add all row totals.
Input rows 1–3, columns 2–4. The window moves 1 cell per output step.
| 10 | 9 | 5 | 6 |
| 5 | 7 | 6 | 7 |
| 3 | 3 | 2 | 8 |
| 3 | 2 | 6 | 7 |
Only the outlined cells belong to this output.
| 1 | 1 | 1 |
| 1 | 2 | 1 |
| 1 | 1 | 1 |
Same row and column positions; no matrix multiplication.
| 9 | 5 | 6 |
| 7 | 12 | 7 |
| 3 | 2 | 8 |
Each cell is input × matching kernel coefficient.
20 + 26 + 13 = 59
| 57 | 59 |
| 40 | 50 |
Output row 1, column 2.
Window row 1.
R_1=(9)\times(1)+(5)\times(1)+(6)\times(1)=20Window row 2.
R_2=(7)\times(1)+(6)\times(2)+(7)\times(1)=26Window row 3.
R_3=(3)\times(1)+(2)\times(1)+(8)\times(1)=13Add the rows to obtain one output cell.
Y_{1,2}=(20)+(26)+(13)=59Output position (2, 1)
Use this position's input window. Multiply corresponding entries row by row; then add all row totals.
Input rows 2–4, columns 1–3. The window moves 1 cell per output step.
| 10 | 9 | 5 | 6 |
| 5 | 7 | 6 | 7 |
| 3 | 3 | 2 | 8 |
| 3 | 2 | 6 | 7 |
Only the outlined cells belong to this output.
| 1 | 1 | 1 |
| 1 | 2 | 1 |
| 1 | 1 | 1 |
Same row and column positions; no matrix multiplication.
| 5 | 7 | 6 |
| 3 | 6 | 2 |
| 3 | 2 | 6 |
Each cell is input × matching kernel coefficient.
18 + 11 + 11 = 40
| 57 | 59 |
| 40 | 50 |
Output row 2, column 1.
Window row 1.
R_1=(5)\times(1)+(7)\times(1)+(6)\times(1)=18Window row 2.
R_2=(3)\times(1)+(3)\times(2)+(2)\times(1)=11Window row 3.
R_3=(3)\times(1)+(2)\times(1)+(6)\times(1)=11Add the rows to obtain one output cell.
Y_{2,1}=(18)+(11)+(11)=40Output position (2, 2)
Use this position's input window. Multiply corresponding entries row by row; then add all row totals.
Input rows 2–4, columns 2–4. The window moves 1 cell per output step.
| 10 | 9 | 5 | 6 |
| 5 | 7 | 6 | 7 |
| 3 | 3 | 2 | 8 |
| 3 | 2 | 6 | 7 |
Only the outlined cells belong to this output.
| 1 | 1 | 1 |
| 1 | 2 | 1 |
| 1 | 1 | 1 |
Same row and column positions; no matrix multiplication.
| 7 | 6 | 7 |
| 3 | 4 | 8 |
| 2 | 6 | 7 |
Each cell is input × matching kernel coefficient.
20 + 15 + 15 = 50
| 57 | 59 |
| 40 | 50 |
Output row 2, column 2.
Window row 1.
R_1=(7)\times(1)+(6)\times(1)+(7)\times(1)=20Window row 2.
R_2=(3)\times(1)+(2)\times(2)+(8)\times(1)=15Window row 3.
R_3=(2)\times(1)+(6)\times(1)+(7)\times(1)=15Add the rows to obtain one output cell.
Y_{2,2}=(20)+(15)+(15)=50Final output: LaTeX:
\begin{bmatrix}57 & 59\\40 & 50\end{bmatrix}. Each output came from its own complete window; stride changes the next window position, not the multiplication rule.