Image Classification with ResNet (continued)
ECE 57000 — October 23, 2026
Architectural choices need evidence and a matching output
- CNN locality and sharing helped under our measured recipe, but did not guarantee shift robustness.
- Residual blocks add learned updates and a direct gradient path; normalization groups selected values.
- BatchNorm uses current-batch statistics during training and stored running statistics in default evaluation mode.
Today: finish ResNet-18 and U-Net, then define the prediction task for sequence models.
Normalization layers differ in which values share statistics
| BatchNorm |
One channel across examples and spatial positions |
| InstanceNorm |
One channel’s spatial positions within one example |
| GroupNorm |
A group of channels and spatial positions within one example |
| LayerNorm |
Chosen trailing feature dimensions within one example |
ResNet-18 uses BatchNorm. The U-Net example uses InstanceNorm.
The other three need no cross-example statistics. LayerNorm will return when we discuss transformers.
Pooling either reduces a map or summarizes each channel
![Local max pooling turns a four-by-four map into two-by-two local maxima. Global average pooling gives one average for each channel.]()
ResNet uses both: local pooling near the input; global averaging before the classification head.
ResNet-18 uses smaller spatial maps and more channels
![Annotated ResNet-18 architecture. RGB 224-square input passes through convolution, normalization and pooling, four residual stages with 64 to 512 channels, global average pooling and a linear classifier. An inset shows the basic block and shape-changing shortcut.]()
Image Segmentation with U-Net
Segmentation needs a prediction at every image location
Arc 5: CNN fundamentals → evidence → ResNet classification → U-Net segmentation.
Task → Upsampling → Architecture
A classifier summarizes an image. A segmentation model must retain where each class occurs.
A road map needs a label at every pixel
![An actual Massachusetts aerial RGB image crop beside its supplied binary road annotation. White mask pixels indicate roads.]()
Transposed convolution uses the transpose of the linear operator
![A convolution matrix maps six flattened inputs to two outputs. Its transpose reverses the connections and maps two inputs to six outputs, without guaranteeing inversion.]()
\[\boldsymbol{y}=A_K\boldsymbol{x}\qquad\longrightarrow\qquad\boldsymbol{u}=A_K^{\mathsf T}\boldsymbol{z}\]
Fractional-stride intuition explains learned spatial expansion
![A stride-two transposed convolution of inputs two and three with kernel one-two-one scatters overlapping patches, summing to two-four-five-six-three.]()
In 2D, ConvTranspose2d(16, 8, 2, stride=2) maps \([B,16,16,16]\) to \([B,8,32,32]\).
U-Net combines coarse context with fine-resolution features
The U-Net head keeps one score vector at every pixel
![The last U-Net stage concatenates two 32-channel full-resolution maps, fuses 64 channels to 32, and uses a one-by-one head to output two logits at each pixel.]()
The task determines what the architecture must preserve
- Classification: aggregate spatial features into an image-level decision.
- Segmentation: combine broad context with location-specific detail.
- Both: architectural choices need evidence on the intended data and task.
We can now read complete architectures from familiar operations. Knowing the pieces does not show that a model solves the application.
Sequence Prediction and Representation
David I. Inouye
Dynamic Content · Last Updated: October 23, 2026
A completion assistant needs a task, examples and a way to use context
Arc 6: Sequence-model architectures
- Define the task: what is given, and what should come next?
- Build training examples: tokens, learned features and shifted targets.
- Choose the context model: fixed window, recurrent state, then attention.
We will follow one email-completion example through each choice.
Sequence tasks differ in what goes in and what comes out
![Five input-output patterns: multiple email tokens to one category, one image to multiple caption tokens, one label per input token, audio sequence to a different-length transcript, and a prefix to its next token. Inputs are below and outputs above.]()
Our focus: next-token completion. Repeating it generates a continuation.
Email autocomplete suggests the next few words while you write
Typed prefix: “please send the”
Possible continuations: “report” · “slides” · “agenda”
- The writer supplies the message and accepts or ignores a suggestion.
- We predict the next token, then repeat to suggest a short continuation.
- Suggestions should fit the prefix and arrive quickly.
First: turn text into choices the model can predict.
Token IDs identify choices without ordering their meanings
Synthetic vocabulary for the worked examples:
please send the report becomes the ID sequence \((1,2,3,4)\).
- IDs select categories; subtracting two IDs does not measure similarity.
- A token can be a word, a word piece, punctuation, or a special marker.
Next: turn each ID into learned features.
An embedding table learns features for each token
Synthetic table \(E\in\mathbb{R}^{6\times2}\):
<BOS> |
0 |
0 |
please |
1 |
0 |
send |
0 |
1 |
the |
1 |
1 |
report |
1 |
−1 |
<EOS> |
−1 |
0 |
For token ID \(w_t=2\) (send):
\[\boldsymbol{e}_t=E^{\mathsf T}\boldsymbol{o}_2
=\begin{bmatrix}0\\1\end{bmatrix}\]
\(\boldsymbol{o}_2=[0,0,1,0,0,0]^{\mathsf T}\) selects row 2.
- Lookup selects the same learned row wherever a token occurs.
- Training updates that row through the prediction loss.
Next: specify the target that teaches these features.