3.4.14 · D1Convolutional Neural Networks

Foundations — Semantic segmentation (U-Net, FCN)

3,172 words14 min readBack to topic

Before you can read the parent note comfortably, you need a small toolbox of ideas: what a pixel actually is, what a "feature map" is, what those shapes with depth mean, why convolutions shrink images, and what "upsampling" even does. This page builds every one of them from the ground up. Nothing here assumes you have seen the notation before line one.


1. The pixel — the atom of the whole topic

Figure 1 below is our reference grid — every later idea is really a statement about it.

Figure — Semantic segmentation (U-Net, FCN)

In Figure 1, each cell is one pixel, and the yellow-outlined cell holds a stack of 3 numbers (R, G, B) drawn to its right. "Classifying a pixel" (the whole job of segmentation) means: given that little stack of numbers and its neighbours, decide which class this square belongs to — road, car, sky.


2. Reading the shape notation

Images and the network's internal data are all rectangular stacks of numbers. We describe their size with three letters.

So means "a grid tall, wide, with a stack of 3 numbers behind each square."

Figure 2 shows this box picture.

Figure — Semantic segmentation (U-Net, FCN)

In Figure 2 the front face is (the spatial layout you'd see), and the depth going backwards is (the numbers you don't see spatially — they live "behind" each pixel). This box picture is the single most useful mental model for the entire parent note.


3. The feature map — the box inside the network

Between input and output the network holds many boxes, called feature maps.

When the parent says " feature map," read it as: a box only tall and wide (very coarse — few positions left) but numbers deep (very rich — lots of learned patterns, so here). That trade — small in space, huge in depth — is the heart of why segmentation is hard.


4. Convolution and why it shrinks the picture

Two knobs control what comes out:

Figure 3 shows why the picture shrinks.

Figure — Semantic segmentation (U-Net, FCN)

In Figure 3: the yellow window sits on the blue input. Because it must fit entirely inside, its centre can never touch the outer border — so with no padding a input becomes a output. Convolutions with no padding shrink the picture by each time. This is exactly why the parent's U-Net example goes (two convs remove ).

Before we write the output-size formula, one small piece of notation:

Two padding modes you must know


5. Pooling — the other way images shrink

This is the aggressive downsampling the parent complains about. See Pooling Layers for the full treatment. Picture it as summarising each little neighbourhood by its loudest response — you keep the presence of a feature but lose exactly where inside the window it was.


6. Upsampling — growing the box back

To turn a coarse box back into a prediction we must enlarge it. There are two families of ways to do this.

6a. Fixed (non-learned) upsampling

6b. Learned upsampling — the transposed convolution

Figure 4 shows this.

Figure — Semantic segmentation (U-Net, FCN)

In Figure 4 a input (blue) is spread out with zeros (grey) into a larger grid, then a kernel (yellow) sweeps it to fill in real numbers — the output (green) is bigger than the input. Because the kernel's weights are learned, the network discovers its own way to fill the gaps, rather than using the fixed rules of 6a.

Notice this is the ordinary-convolution formula rearranged to grow instead of shrink — that's literally why it's called transposed.


7. Two ways to merge skip connections: add vs. concatenate

Both FCN and U-Net glue a deep (semantic) box to a shallow (detailed) box. First we name the two boxes the parent's formula uses.

The symbol just means "real numbers" — so reads "a box of that shape filled with ordinary decimal numbers."

The cropping catch (valid padding only)


8. The training symbols: logits, softmax, cross-entropy

The parent's loss formula looks scary; every piece is simple.

The double sum is nothing exotic — it just says "do this for every row and every column ," i.e. every pixel in the grid from Section 1. See Loss Functions for cross-entropy in full generality.

Recall Why divide by

? Averaging (not just summing) keeps the loss the same scale regardless of image size, so learning rates behave consistently across resolutions.


Prerequisite map

Pixel grid R G B

Shape notation H x W x channels

Feature map box

Convolution shrinks valid or same pad

Pooling shrinks

Upsampling fixed or learned

Skip merge Ei and Di add or concat

Crop or same pad to align sizes

Logits softmax cross entropy

Semantic segmentation U-Net FCN

Every prerequisite box flows into the parent topic on the right. Notice both shrinking (conv, pool) and growing (upsampling) feed in — that push-and-pull is the U-shape.


Equipment checklist

Cover the right side and answer aloud; reveal to check.

What does a single pixel of a colour image store?
Three numbers — Red, Green, Blue intensity, each 0–255.
In , what does each letter mean?
Height (rows), Width (columns), Channels (numbers stacked behind each pixel).
Why do we distinguish from ?
counts channels (box depth); counts classes. They're unrelated except at the final layer where box depth equals number of classes.
Why is the output label map shape and not ?
Each pixel needs only ONE class-ID number, so no channel depth is required.
Why does a valid convolution shrink a input to ?
The window's centre can't reach the border, losing pixels per side.
What is the difference between valid and same padding?
Valid () shrinks the output; same padding adds zeros so stride-1 output keeps the input size.
What does the floor function do?
Rounds down to the nearest whole number, since pixel counts must be integers.
What do stride and padding each control?
Stride = how far the window jumps (bigger stride, smaller output); padding = zero-rings added so the window reaches the edges.
What does max pooling keep and what does it throw away?
Keeps the largest value in each window (the feature's presence); throws away its exact within-window location.
Name two fixed upsampling methods and their trade-off.
Nearest-neighbour (blocky) and bilinear (smooth); both are parameter-free but can't invent lost sharp boundaries.
How does a transposed convolution enlarge a feature map, and how does it differ from fixed upsampling?
It inserts zeros then runs a LEARNED convolution; unlike fixed methods its filling is trained, not a fixed rule.
Why is "deconvolution" a misleading name for it?
It restores the SIZE only, not the lost values — it does not invert the original convolution.
What are and in the skip formula?
= encoder feature map at level (fine detail); = decoder feature map at level (deep semantics).
Difference between add and concatenate for skip connections?
Add needs equal shapes and blends into one box; concat stacks channels () and lets later layers choose.
With valid padding, why must you crop before concatenating?
Encoder boxes are slightly larger (border nibbled by convs), so they're centre-cropped (e.g. ) to match the decoder size; same padding avoids this.
What does softmax do and why use the exponential?
Turns raw class scores into probabilities summing to 1; the exponential keeps everything positive, is smooth, and is differentiable for training.
In the loss, what does the double sum range over?
Every pixel — all rows and all columns of the grid.
Why divide the loss by ?
To average per pixel so the loss scale is independent of image size.

Related tools you'll meet later: Pooling Layers, Residual Networks (ResNet), Transfer Learning, Data Augmentation, Batch Normalization, Loss Functions, Object Detection, Attention Mechanisms. Back to the parent: Semantic segmentation (U-Net, FCN).