Lecture L5 · Decoder

U-Net — the decoder that paints the damage map

A symmetric expanding path that takes the encoder's tiny 7×7 feature map and grows it back to a full 224×224 per-pixel damage map. Skip connections from the encoder restore the fine spatial detail that downsampling discarded.

Encoder (contracting path) — features from ResNet-50Decoder (expanding path) — U-NetEnc 0 (stem features)64 × 224 × 224Enc 1 (Stage 1)256 × 56 × 56Enc 2 (Stage 2)512 × 28 × 28Enc 3 (Stage 3)1024 × 14 × 14Enc 4 (Stage 4 / bottom)2048 × 7 × 7Dec 4 — UpConv + DoubleConv1024 × 14 × 14Dec 3 — UpConv + DoubleConv512 × 28 × 28Dec 2 — UpConv + DoubleConv256 × 56 × 56Dec 1 — UpConv + DoubleConv64 × 112 × 112Dec 0 — UpConv + DoubleConv32 × 224 × 224skip ⓫ (concat 64-ch)skip ⓫ (concat 256-ch)skip ⓫ (concat 512-ch)skip ⓫ (concat 1024-ch)bottom: bridge ⑫ (no skip — deepest features pass through)1×1 conv → softmax ⑬5 channels × 224 × 224damage class per pixelZoom: one decoder stage ⑭UpConv 2×transposed 2×2Concatwith skip3×3 convBN + ReLU3×3 convBN + ReLUDropoutp = 0.1→ next stage2× resolution
In plain English — read this first

The encoder squeezed our photo down to a tiny 7×7 grid full of meaning. The decoder's job is the opposite: blow that grid back up to a full 224×224 colour-coded damage map, one of five classes per pixel (no damage, minor, moderate, major, destroyed). Naively upsampling alone gives a blurry blob. The trick is the skip connections: at every level, we paste the encoder's same-resolution feature map back in, so the decoder knows both what a region is (from deep features) and whereit ends (from early features).

  • UpConv (transposed 2×2) = a learned "zoom in 2×" — doubles height and width.
  • Concat = stick two feature maps together along the channel axis (like stacking transparencies).
  • DoubleConv = two 3×3 convs back-to-back, each with BN + ReLU. The first halves channels; the second refines.
  • 1×1 conv at the end = a tiny per-pixel classifier that maps the final 32-channel map to 5 damage-class scores.
  • The whole network is shaped like a "U" — encoder going down on the left, decoder coming back up on the right, skip arrows crossing the middle.
Figure walkthrough
  1. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ① Enc 0 (stem features, 64 × 224 × 224) — the very first encoder output. Same resolution as the input; holds crisp edges and colour gradients. We will use it to place razor-sharp damage boundaries at the end.
  2. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ② Enc 1 / Stage 1 (256 × 56 × 56) — local textures (roof shingles, vegetation, asphalt).
  3. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ③ Enc 2 / Stage 2 (512 × 28 × 28) — object parts (a window, a wall section, a car).
  4. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ④ Enc 3 / Stage 3 (1024 × 14 × 14) — mid-level semantics ("intact building", "rubble pile").
  5. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑤ Enc 4 / Stage 4 — the bottom of the U (2048 × 7 × 7) — the deepest, most abstract feature map. This is the "valley" of the U-shape.
  6. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑥ Dec 4 — first up-step — a transposed 2×2 conv doubles the size to 14×14, then DoubleConv fuses it with the Enc 3 skip. Output: 512 × 14 × 14.
  7. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑦ Dec 3 — up to 28×28; concatenates the Enc 2 skip; output 256 × 28 × 28.
  8. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑧ Dec 2 — up to 56×56; concatenates the Enc 1 skip; output 128 × 56 × 56.
  9. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑨ Dec 1 — up to 112×112; output 64 × 112 × 112 (no skip available at 112² — the encoder never stops there).
  10. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑩ Dec 0 — final up-step — up to 224×224; concatenates the Enc 0 skip; output 32 × 224 × 224. We are now back at the original resolution.
  11. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⓫ Skip connections (the four dashed blue arrows) — at each level, the encoder feature map is concatenated (stacked, not added) with the upsampled decoder feature. This is the single biggest reason U-Net beats a plain encoder-decoder: it can read "what is this" from deep features and "where exactly does it end" from shallow features at the same time.
  12. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑫ Bridge (bottom arrow) — the deepest encoder feature flows straight into Dec 4 with no separate skip — Enc 4 is the decoder's input.
  13. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑬ Final 1×1 conv + softmax — projects 32 channels → 5 (one per damage class), then softmax turns those into per-pixel probabilities. argmax over the 5 channels gives the final colour-coded damage map.
  14. E01E12E23E34E45D46D37D28D19D010skip11bridge121×113zoom14
    ⑭ Zoom: one decoder stage — internally each Dec block is: UpConv 2× (doubles H,W) → Concat with the encoder skip → 3×3 conv + BN + ReLU twice (the classic U-Net "double-conv") → tiny Dropout for regularisation → hand off to the next stage. The first 3×3 halves the concatenated channels; the second refines them.
Stage-by-stage tensor shapes
StageInput (from below)Skip inAfter UpConvAfter DoubleConv
Bridge2048 × 7 × 71024 × 7 × 7
Dec 41024 × 7 × 71024 × 14 × 14512 × 14 × 14512 × 14 × 14
Dec 3512 × 14 × 14512 × 28 × 28256 × 28 × 28256 × 28 × 28
Dec 2256 × 28 × 28256 × 56 × 56128 × 56 × 56128 × 56 × 56
Dec 1128 × 56 × 5664 × 112 × 11264 × 112 × 112
Dec 064 × 112 × 11264 × 224 × 22432 × 224 × 22432 × 224 × 224
Head32 × 224 × 2245 × 224 × 224 (softmax)

Note how every up-step halves the channel count and doubles the spatial size, mirroring the encoder's contracting path exactly — that symmetry is the "U".

Why concat (not add) for the skip?
ResNet skips use addition because both tensors have the same channel count. U-Net skips bring in extra information at a different abstraction level, so we want the decoder to learn how to mix them. Concatenation hands both tensors to the next 3×3 conv, which then learns the optimal per-pixel blend through its weights — strictly more expressive than a fixed add.
Acronyms & jargon — quick reference
U-Net
— U-shaped encoder-decoder with skip connections, Ronneberger et al. 2015.
Encoder
— left side: shrinks H/W, grows channels. Asks "what is in the image?"
Decoder
— right side: grows H/W, shrinks channels. Asks "where exactly is it?"
UpConv
— transposed convolution; a learned 2× zoom-in (doubles H and W).
Concat
— stack two tensors along the channel axis (like stacking transparencies).
DoubleConv
— two 3×3 conv + BN + ReLU layers back-to-back; the U-Net "Lego brick".
Skip connection
— same-resolution feature map piped from encoder to decoder.
Bridge / bottom
— deepest layer at the bottom of the "U"; no separate skip.
1×1 conv
— per-pixel linear layer; here projects 32 channels → 5 class scores.
Softmax
— turns the 5 raw scores into probabilities summing to 1 per pixel.
Dropout
— randomly zeros some activations during training to fight overfitting.
Segmentation map
— H×W image where each pixel is a class label (here: damage tier).