
EE 541 - Unit 8A
Fall 2026
Dense first layer: \(\mathbf{s} = \mathbf{W}\mathbf{x} + \mathbf{b}\), one column of \(\mathbf{W}\) per pixel of the flattened \(28 \times 28\) image
Shuffle: one fixed permutation \(\mathbf{P}\) of the \(784\) pixels, the same for every image \[\mathbf{W}\mathbf{x} = (\mathbf{W}\mathbf{P}^T)(\mathbf{P}\mathbf{x})\]
Network: two hidden layers of \(256\) ReLU units, \(50{,}000\) FashionMNIST training images, \(10\) epochs
Neighboring pixels: nothing in \(\mathbf{W}\) marks which columns are neighbors

Column \((i, j)\) of \(\mathbf{W}\) multiplies pixel \((i, j)\) and no other
FashionMNIST is centered: each part of an item at nearly the same pixels in every image
Validation images shifted right by \(t\) pixels, the network trained on centered images

Correlation of two pixels’ intensities over \(20{,}000\) training images \[\rho_{(i,j),(i',j')} = \frac{\mathrm{Cov}(X_{ij}, X_{i'j'})}{\sigma_{ij}\, \sigma_{i'j'}}\]
Average over pixel pairs that vary across images, by distance
Local patterns: edges, stripes, and corners are relations between nearby pixels
Patch: a pixel’s strongest correlations are with its immediate neighbors
Distant correlation: one part of an item with another, such as the two legs of a trouser

Detector: a \(3 \times 3\) array of weights
Feature map: the response at every position, itself an image
Two detectors
Convolution: computing the response at every position

Same kernel at every position: an edge gives the same response wherever it is
Vertical-edge kernel, ankle boot shifted right by \(4\) pixels

Convolutional network: one layer of \(32\) learned \(5 \times 5\) kernels, ReLU, a dense output layer
Dense network: two hidden layers of \(256\) ReLU units, a dense output layer
Training: the same optimizer and batch size, \(10\) epochs
First layer: \(200{,}960 / 832 \approx 242\)

Shift invariance: class scores unchanged by a shift
Dense output layer: one weight per feature-map value and class
Validation images shifted right by \(t\) pixels

Classification: the true class and the five most probable of \(1{,}000\), for each test image A. Krizhevsky, I. Sutskever, G. E. Hinton, “ImageNet Classification with Deep Convolutional Neural Networks,” NIPS 2012, Fig. 4
ImageNet: \(1.2\) million photographs in \(1{,}000\) classes, \(120\) of them dog breeds O. Russakovsky et al., “ImageNet Large Scale Visual Recognition Challenge,” IJCV 2015, Fig. 2
Detection: a box and a class for each object J. Redmon, S. Divvala, R. Girshick, A. Farhadi, “You Only Look Once: Unified, Real-Time Object Detection,” CVPR 2016, Fig. 6
Instance segmentation: a box, a class, and a pixel mask for each object K. He, G. Gkioxari, P. Dollár, R. Girshick, “Mask R-CNN,” ICCV 2017, Fig. 5
Pose estimation: the joints of every person, joined into skeletons Z. Cao, T. Simon, S.-E. Wei, Y. Sheikh, “Realtime Multi-Person 2D Pose Estimation Using Part Affinity Fields,” CVPR 2017, Fig. 1
Semantic segmentation: a class for every pixel, against the ground truth; last row, life jackets labeled as people J. Long, E. Shelhamer, T. Darrell, “Fully Convolutional Networks for Semantic Segmentation,” CVPR 2015, Fig. 6


Cell segmentation: microscope image in, each cell outlined, from \(20\) partially annotated training images O. Ronneberger, P. Fischer, T. Brox, “U-Net: Convolutional Networks for Biomedical Image Segmentation,” MICCAI 2015, Fig. 4c, d
Style transfer: a photograph of Tübingen in the styles of Turner, van Gogh, Munch, Picasso, and Kandinsky L. A. Gatys, A. S. Ecker, M. Bethge, “A Neural Algorithm of Artistic Style,” arXiv 1508.06576, 2015, Fig. 2
Colorization: a grayscale photograph in, a color photograph out R. Zhang, P. Isola, A. A. Efros, “Colorful Image Colorization,” ECCV 2016, Fig. 1
Super-resolution, \(4\times\): SRGAN looks sharpest and scores a lower PSNR than SRResNet C. Ledig et al., “Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network,” CVPR 2017, Fig. 2
Captioning: generated captions, rated by people from without errors to unrelated to the image O. Vinyals, A. Toshev, S. Bengio, D. Erhan, “Show and Tell: A Neural Image Caption Generator,” CVPR 2015, Fig. 5
Attention: the bright region is where the network looked for the underlined word K. Xu et al., “Show, Attend and Tell: Neural Image Caption Generation with Visual Attention,” ICML 2015, Fig. 3
Generation: faces produced by a network, uncurated T. Karras, S. Laine, T. Aila, “A Style-Based Generator Architecture for Generative Adversarial Networks,” CVPR 2019, Fig. 2 (top)
Spectrogram: an audio signal as a grid of time by frequency
Signal: \(440\) Hz tone, chirp from \(500\) to \(2{,}500\) Hz, three clicks
Game screens: Atari frames in, the next action out (Mnih et al. 2013)
One dimension: raw signals and sequences, such as audio and ECG
Three dimensions: video, over time, height, and width
No order: tabular data, whose column order is arbitrary







Low-pass filter: a truncated exponential moving average, \(h[m] \propto 0.6^m\)
Convolution, signal processing \[y[n] = \sum_{m} h[m]\, x[n - m]\]
Impulse response \(h\): the output for a unit impulse
Time invariance: one \(h\) for every \(n\)
Kernel: the weights \(h[m]\), here \(7\) of them
Local: each output depends on the \(7\) samples under the kernel only

Moving average, \(h = [1, \ldots, 1]/7\), low-pass
Difference, \(h = [1, -1]\), step detector
Same sum, different \(h\)
In a convolutional layer: the kernel is learned

Convolution: \(\;(x * h)[n] = \sum_m h[m]\, x[n - m]\)
Correlation: \(\;(x \star h)[n] = \sum_m h[m]\, x[n + m]\)
At an impulse
nn.Conv2d: correlation, plus a bias
Learned kernel










Correlation in 2D \[s[i, j] = \sum_{m=0}^{2}\sum_{n=0}^{2} w[m, n]\, x[i + m,\, j + n]\]
From one dimension
Local: each output depends on one \(3 \times 3\) patch only
Example: \(+1\) right column, \(-1\) left column

Dense unit, one image: \(s = \mathbf{w}^T\mathbf{x} + b\)
Convolutional unit, one patch: \(s[i, j] = \mathbf{w}^T\mathbf{p}_{ij} + b\)
Same computation: a dense unit on \(9\) inputs, repeated at every position

\[s = \mathbf{w}^T\mathbf{p} = \underbrace{\|\mathbf{w}\|}_{\text{kernel}}\;\underbrace{\|\mathbf{p}\|}_{\text{patch norm}}\;\underbrace{\cos\theta}_{\text{alignment}}\]
Kernel in the figure: vertical edge, dark to bright
Decision: pattern \(\mathbf{w}\) present or absent in patch \(\mathbf{p}\)
Hypotheses, noise \(\mathbf{n} \sim \mathcal{N}(\mathbf{0}, \sigma^2\mathbf{I})\)
\[H_1:\; \mathbf{p} = \mathbf{w} + \mathbf{n} \qquad H_0:\; \mathbf{p} = \mathbf{n}\]
Conditions
Correlated noise \(\boldsymbol{\Sigma}\): kernel \(\boldsymbol{\Sigma}^{-1}\mathbf{w}\)
Log-likelihood ratio
\[\log \Lambda(\mathbf{p}) = \frac{\|\mathbf{p}\|^2 - \|\mathbf{p} - \mathbf{w}\|^2}{2\sigma^2} = \frac{\mathbf{w}^T\mathbf{p}}{\sigma^2} - \frac{\|\mathbf{w}\|^2}{2\sigma^2}\]
Gaussian classes with a shared covariance: weights \(\boldsymbol{\Sigma}^{-1}(\boldsymbol{\mu}_1 - \boldsymbol{\mu}_0) = \mathbf{w}/\sigma^2\)
Test
\[\Lambda(\mathbf{p}) > \eta \iff \mathbf{w}^T\mathbf{p} > T = \frac{\|\mathbf{w}\|^2}{2} + \sigma^2 \log\eta\]
Matched filter: kernel = the pattern \(\mathbf{w}\)

Per pixel
Kernel output, \(784\) pixels
Unit-norm kernel: output noise \(\sigma = 0.35\)
Peak 2.88, noise standard deviation \(0.35\)
8 standard deviations
Gain \(\sqrt{784} = 28\) over one pixel
Largest response: row 30, column 50, where the sandal was placed

Sobel kernels: a gradient estimate, built by design
\[\begin{bmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \\ 1 \end{bmatrix} \begin{bmatrix} -1 & 0 & 1 \end{bmatrix}\]
Edge magnitude: \(\sqrt{s_v^2 + s_h^2}\)
I. Sobel and G. Feldman, “An Isotropic 3×3 Image Gradient Operator,” Stanford AI Project, 1968. Photograph: guitar by Manuel Ramírez, 1912, The Metropolitan Museum of Art (CC0)

AlexNet: a convolutional network, \(5\) convolutional layers, then \(3\) dense layers, trained on ImageNet
First layer, shown: \(64\) kernels, weights fit by gradient descent
Learned
Operation: correlation, as with the Sobel kernels
torchvision AlexNet, ImageNet weights: \(64\) kernels, the one-GPU network of A. Krizhevsky, arXiv 1404.5997, 2014 (the 2012 network has \(96\))

\(\mathbf{s} = \mathbf{W}\mathbf{x}\), the \(5 \times 5\) example flattened row by row
Row \((i, j)\) of \(\mathbf{W}\): the kernel’s \(9\) values at the columns of patch \((i, j)\)
Sparse: zero outside the patch, \(81\) of \(225\) entries on a patch, \(54\) of them nonzero
Shared: the same \(9\) values in every row
Backward pass: \(\partial\ell/\partial\mathbf{x} = \mathbf{W}^T\,\partial\ell/\partial\mathbf{s}\)


Number of weights, \(N \times N\) input, \(3 \times 3\) kernel
At \(N = 28\): \(529{,}984\), \(6{,}084\), \(9\)
Multiplications: \(9\,(N-2)^2\), with or without sharing
Input shifted right by \(t\), zero fill: \(x'[i, j] = x[i, j - t]\)
\[s'[i, j] = \sum_{m, n} w[m, n]\, x[i + m,\, j - t + n] = s[i, j - t]\]
Equivariant: input shifted by \(t\), output shifted by \(t\)
Condition: \(w[m, n]\) independent of \((i, j)\)
Borders: equality for \(j \ge t\)
Signal-processing name: shift invariance of the system


Gray value: \(0.299R + 0.587G + 0.114B\)
Purple sky, orange horizon
Sobel on the red channel alone: edge detected
Sobel on gray: \(s = 0\) at the boundary

Input: \(C_{\text{in}}\) channels
Kernel: \(C_{\text{in}} \times k \times k\) weights, one \(k \times k\) slice per channel
\[s[i, j] = \sum_{c=1}^{C_{\text{in}}} \sum_{m, n} w[c, m, n]\; x[c, i + m,\, j + n] + b\]
Example: purple against orange, equal gray

Weights: \(C_{\text{out}} \times C_{\text{in}} \times k \times k\), one bias per output channel
Output: \(C_{\text{out}}\) maps, a \(C_{\text{out}}\)-channel image
Kernels shown: \(4\) of the \(64\) first-layer kernels of torchvision’s AlexNet, on a CIFAR-10 image

Layer 1: \(2\) kernels, \(2\) output channels
Layer 2, set by hand: kernel of shape \(2 \times 3 \times 3\), one slice per edge channel
Shapes: \((N, C_{\text{in}}, H, W) \to (N, C_{\text{out}}, H - k + 1, W - k + 1)\)
Parameters: \(C_{\text{out}}(C_{\text{in}} k^2 + 1)\)
Fan-in: \(C_{\text{in}} k^2 = 27\)
Next layer: in_channels = this layer’s out_channels
Layer: nn.Conv2d(16, 32, 3, padding=1) on a \(64 \times 64\) input
Parameters
Multiply–accumulate operations (MACs): one multiply, one add into the running sum
MACs per parameter
Fewer parameters: \(1{,}851{,}307\) times fewer than dense
More computation per parameter: each weight used at all \(4{,}096\) positions

Network, \(32 \times 32 \times 3\) input
MACs per layer: weights × output positions
MACs per weight: \(784\) in conv 2, \(1\) in the dense layer

One \(3 \times 3\) layer: each unit depends on a \(3 \times 3\) input region
\(L\) layers: \((2L + 1) \times (2L + 1)\)
Maps kept at \(32 \times 32\), \(64\) channels: the same cost at every layer
Cost: 0.6 billion MACs per image for \(16\) layers, linear in \(L\)