# F22 Q1a

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/15/tee-c15-s0

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

## Question

**Question (4 marks).** A normalized 5 × 5 image has every row [0.5,0.5,0.3,0.3,0.3]. Convolve it with a 3 × 3 filter whose every row is [1,0,−1], stride 2, no padding. Compute the output and identify the feature.

## Answer — step by step

### Given

A normalized 5 × 5 image has every row [0.5,0.5,0.3,0.3,0.3].

Convolve it with a 3 × 3 filter whose every row is [1,0,−1], stride 2, no padding.

### 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}+b
$$



**Yaad 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:**   $\left\lfloor\frac{5+2 \times  0-3}{2}\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.

Follow window (1, 1) into one output cell

Input rows **1–3**, columns **1–3**. The window moves **2** cells per output step.

1. Select the input window

1. Select the input window

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |

Only the outlined cells belong to this output.

2. Match the kernel

2. Match the kernel

|  |  |  |
| --- | --- | --- |
| 1 | 0 | −1 |
| 1 | 0 | −1 |
| 1 | 0 | −1 |

Same row and column positions; no matrix multiplication.

3. Multiply cell by cell

3. Multiply cell by cell

|  |  |  |
| --- | --- | --- |
| 0.5 | 0 | −0.3 |
| 0.5 | 0 | −0.3 |
| 0.5 | 0 | −0.3 |

Each cell is input × matching kernel coefficient.

4. Add the products row by row

Row 1**0.5 + 0 + (−0.3) = 0.2**

Row 2**0.5 + 0 + (−0.3) = 0.2**

Row 3**0.5 + 0 + (−0.3) = 0.2**

**0.2 + 0.2 + 0.2 = 0.6**

5. Place it in the output

5. Place it in the output

|  |  |
| --- | --- |
| 0.6 | 0 |
| 0.6 | 0 |

Output row 1, column 1.

**Window row 1.**



$$
R_1=(0.5)\times(1)+(0.5)\times(0)+(0.3)\times(-1)=0.2
$$



**Window row 2.**



$$
R_2=(0.5)\times(1)+(0.5)\times(0)+(0.3)\times(-1)=0.2
$$



**Window row 3.**



$$
R_3=(0.5)\times(1)+(0.5)\times(0)+(0.3)\times(-1)=0.2
$$



**Add the rows to obtain one output cell.**



$$
Y_{1,1}=(0.2)+(0.2)+(0.2)=0.6
$$



### Output position (1, 2)

Use this position's input window. Multiply corresponding entries row by row; then add all row totals.

Follow window (1, 2) into one output cell

Input rows **1–3**, columns **3–5**. The window moves **2** cells per output step.

1. Select the input window

1. Select the input window

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |

Only the outlined cells belong to this output.

2. Match the kernel

2. Match the kernel

|  |  |  |
| --- | --- | --- |
| 1 | 0 | −1 |
| 1 | 0 | −1 |
| 1 | 0 | −1 |

Same row and column positions; no matrix multiplication.

3. Multiply cell by cell

3. Multiply cell by cell

|  |  |  |
| --- | --- | --- |
| 0.3 | 0 | −0.3 |
| 0.3 | 0 | −0.3 |
| 0.3 | 0 | −0.3 |

Each cell is input × matching kernel coefficient.

4. Add the products row by row

Row 1**0.3 + 0 + (−0.3) = 0**

Row 2**0.3 + 0 + (−0.3) = 0**

Row 3**0.3 + 0 + (−0.3) = 0**

**0 + 0 + 0 = 0**

5. Place it in the output

5. Place it in the output

|  |  |
| --- | --- |
| 0.6 | 0 |
| 0.6 | 0 |

Output row 1, column 2.

**Window row 1.**



$$
R_1=(0.3)\times(1)+(0.3)\times(0)+(0.3)\times(-1)=0
$$



**Window row 2.**



$$
R_2=(0.3)\times(1)+(0.3)\times(0)+(0.3)\times(-1)=0
$$



**Window row 3.**



$$
R_3=(0.3)\times(1)+(0.3)\times(0)+(0.3)\times(-1)=0
$$



**Add the rows to obtain one output cell.**



$$
Y_{1,2}=(0)+(0)+(0)=0
$$



### Output position (2, 1)

Use this position's input window. Multiply corresponding entries row by row; then add all row totals.

Follow window (2, 1) into one output cell

Input rows **3–5**, columns **1–3**. The window moves **2** cells per output step.

1. Select the input window

1. Select the input window

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |

Only the outlined cells belong to this output.

2. Match the kernel

2. Match the kernel

|  |  |  |
| --- | --- | --- |
| 1 | 0 | −1 |
| 1 | 0 | −1 |
| 1 | 0 | −1 |

Same row and column positions; no matrix multiplication.

3. Multiply cell by cell

3. Multiply cell by cell

|  |  |  |
| --- | --- | --- |
| 0.5 | 0 | −0.3 |
| 0.5 | 0 | −0.3 |
| 0.5 | 0 | −0.3 |

Each cell is input × matching kernel coefficient.

4. Add the products row by row

Row 1**0.5 + 0 + (−0.3) = 0.2**

Row 2**0.5 + 0 + (−0.3) = 0.2**

Row 3**0.5 + 0 + (−0.3) = 0.2**

**0.2 + 0.2 + 0.2 = 0.6**

5. Place it in the output

5. Place it in the output

|  |  |
| --- | --- |
| 0.6 | 0 |
| 0.6 | 0 |

Output row 2, column 1.

**Window row 1.**



$$
R_1=(0.5)\times(1)+(0.5)\times(0)+(0.3)\times(-1)=0.2
$$



**Window row 2.**



$$
R_2=(0.5)\times(1)+(0.5)\times(0)+(0.3)\times(-1)=0.2
$$



**Window row 3.**



$$
R_3=(0.5)\times(1)+(0.5)\times(0)+(0.3)\times(-1)=0.2
$$



**Add the rows to obtain one output cell.**



$$
Y_{2,1}=(0.2)+(0.2)+(0.2)=0.6
$$



### Output position (2, 2)

Use this position's input window. Multiply corresponding entries row by row; then add all row totals.

Follow window (2, 2) into one output cell

Input rows **3–5**, columns **3–5**. The window moves **2** cells per output step.

1. Select the input window

1. Select the input window

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |
| 0.5 | 0.5 | 0.3 | 0.3 | 0.3 |

Only the outlined cells belong to this output.

2. Match the kernel

2. Match the kernel

|  |  |  |
| --- | --- | --- |
| 1 | 0 | −1 |
| 1 | 0 | −1 |
| 1 | 0 | −1 |

Same row and column positions; no matrix multiplication.

3. Multiply cell by cell

3. Multiply cell by cell

|  |  |  |
| --- | --- | --- |
| 0.3 | 0 | −0.3 |
| 0.3 | 0 | −0.3 |
| 0.3 | 0 | −0.3 |

Each cell is input × matching kernel coefficient.

4. Add the products row by row

Row 1**0.3 + 0 + (−0.3) = 0**

Row 2**0.3 + 0 + (−0.3) = 0**

Row 3**0.3 + 0 + (−0.3) = 0**

**0 + 0 + 0 = 0**

5. Place it in the output

5. Place it in the output

|  |  |
| --- | --- |
| 0.6 | 0 |
| 0.6 | 0 |

Output row 2, column 2.

**Window row 1.**



$$
R_1=(0.3)\times(1)+(0.3)\times(0)+(0.3)\times(-1)=0
$$



**Window row 2.**



$$
R_2=(0.3)\times(1)+(0.3)\times(0)+(0.3)\times(-1)=0
$$



**Window row 3.**



$$
R_3=(0.3)\times(1)+(0.3)\times(0)+(0.3)\times(-1)=0
$$



**Add the rows to obtain one output cell.**



$$
Y_{2,2}=(0)+(0)+(0)=0
$$



**Final output:**   $\begin{bmatrix}0.6 & 0\\0.6 & 0\end{bmatrix}$ . Each output came from its own complete window; stride changes the next window position, not the multiplication rule.

The filter compares left and right neighborhoods and responds to a vertical brightness boundary. Inputs are already normalized. No additional output-normalization rule is supplied, so the determined convolution is  $\begin{bmatrix}0.6 & 0\\0.6 & 0\end{bmatrix}$ . If an examiner explicitly requests min-max normalization of this result, divide by 0.6 to obtain  $\begin{bmatrix}1 & 0\\1 & 0\end{bmatrix}$ ; that is a separate stated operation.
