# R25 Q1c · CNN hierarchy and stride-two convolution

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/21/tee-c21-s2

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

## Question

**Question. Explain why CNNs use a hierarchy of convolutional layers. Apply the printed3×3kernel to the5×5input with stride2.** (5 marks)

## Answer — step by step

Early layers learn local edge/texture patterns; deeper layers combine them into parts and class-relevant configurations, with a growing receptive field. Nonlinearities make stacked layers more expressive than one linear convolution.

### Given

Input:



$$
\begin{bmatrix}2&3&8&2&3\\2&2&4&4&6\\1&2&1&2&9\\7&5&3&3&2\\2&4&3&5&4\end{bmatrix}
$$



Kernel:



$$
\begin{bmatrix}1&0&1\\2&4&0\\6&4&2\end{bmatrix}
$$



Stride=2, zero padding=0, no bias supplied.

### To find

Valid cross-correlation output (CNN convention, no kernel flip).

### Formula: which one and why



$$
O=\left\lfloor\frac{N+2P-F}{S}\right\rfloor+1
$$



Multiply corresponding cells and sum. Here O=⌊(5−3)/2⌋+1=2 in each direction.

### Step 1. Output (1,1) from input top-left (1,1)



$$
\begin{bmatrix}2&3&8\\2&2&4\\1&2&1\end{bmatrix}
$$



2×1 + 3×0 + 8×1 + 2×2 + 2×4 + 4×0 + 1×6 + 2×4 + 1×2 = 2 + 0 + 8 + 4 + 8 + 0 + 6 + 8 + 2 = 38

### Step 2. Output (1,2) from input top-left (1,3)



$$
\begin{bmatrix}8&2&3\\4&4&6\\1&2&9\end{bmatrix}
$$



8×1 + 2×0 + 3×1 + 4×2 + 4×4 + 6×0 + 1×6 + 2×4 + 9×2 = 8 + 0 + 3 + 8 + 16 + 0 + 6 + 8 + 18 = 67

### Step 3. Output (2,1) from input top-left (3,1)



$$
\begin{bmatrix}1&2&1\\7&5&3\\2&4&3\end{bmatrix}
$$



1×1 + 2×0 + 1×1 + 7×2 + 5×4 + 3×0 + 2×6 + 4×4 + 3×2 = 1 + 0 + 1 + 14 + 20 + 0 + 12 + 16 + 6 = 70

### Step 4. Output (2,2) from input top-left (3,3)



$$
\begin{bmatrix}1&2&9\\3&3&2\\3&5&4\end{bmatrix}
$$



1×1 + 2×0 + 9×1 + 3×2 + 3×4 + 2×0 + 3×6 + 5×4 + 4×2 = 1 + 0 + 9 + 6 + 12 + 0 + 18 + 20 + 8 = 74

### Final answer



$$
\begin{bmatrix}38&67\\70&74\end{bmatrix}
$$



**Source / convention note.** Padding is not specified; valid/no-padding is declared. CNN cross-correlation convention is used without kernel reversal.
