Deep Learning · TEE · section
Faculty example: combine three RGB channel sums
Convolutional neural networks
Question. At one position, a convolutional filter receives the following red, green and blue 3 × 3 patches and matching kernel slices. Calculate one output value with bias 1. (Practice: 3 marks)
Given
Red patch = LaTeX:
\begin{bmatrix}0 & 0 & 0\\0 & 156 & 155\\0 & 153 & 154\end{bmatrix}; red kernel = LaTeX:
\begin{bmatrix}-1 & -1 & 1\\0 & 1 & -1\\0 & 1 & 1\end{bmatrix}.
Green patch = LaTeX:
\begin{bmatrix}0 & 0 & 0\\0 & 167 & 166\\0 & 164 & 165\end{bmatrix}; green kernel = LaTeX:
\begin{bmatrix}1 & 0 & 0\\1 & -1 & -1\\1 & 0 & -1\end{bmatrix}.
Blue patch = LaTeX:
\begin{bmatrix}0 & 0 & 0\\0 & 163 & 162\\0 & 160 & 161\end{bmatrix}; blue kernel = LaTeX:
\begin{bmatrix}0 & 1 & 1\\0 & 1 & 0\\1 & -1 & 1\end{bmatrix}. Bias = 1.
These are three slices of one full-depth filter, not three independent output filters.
To find
The contribution of each input channel and the final scalar output at this position.
Formula — which one and why
Multiply corresponding entries within each channel. Add the three channel sums because this filter spans all input channels. Add its single bias once, after accumulating the channel contributions.
z=s_R+s_G+s_B+bThe quantities s_R, s_G and s_B are intermediate weighted sums, not separate final output channels.
Solution — step by step
Step 1: red-channel products. The top row and first column contribute zero. The remaining terms are 156×1 + 155×(−1) + 153×1 + 154×1.
Step 2: red-channel sum. 156 − 155 + 153 + 154 = 308.
Step 3: green-channel products. The remaining patch terms are 167×(−1) + 166×(−1) + 164×0 + 165×(−1).
Step 4: green-channel sum. −167 −166 +0 −165 = −498.
Step 5: blue-channel products. The nonzero-patch terms are 163×1 + 162×0 + 160×(−1) + 161×1.
Step 6: blue-channel sum. 163 +0 −160 +161 = 164.
Step 7: add the channel contributions. 308 −498 +164 = −26.
Step 8: add one filter bias. −26 +1 = −25.
Final answer: The convolution output is −25. If a subsequent ReLU is explicitly requested, that activation produces max(0,−25) = 0. The convolution value and activated value are different stages.
Yaad rakho: Teen channels ka contribution jodo; ek filter ka bias ek baar jodo.