Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Remember where the maxima were
When a network shrinks an image with max pooling, it keeps the strongest value in each small window and forgets where in the window it was. SegNet writes down that position, a tiny note of 2 bits per window. When the decoder grows the map back, it puts each value exactly where it came from, leaving the rest empty, and learned convolutions fill in the gaps. Edges stay in the right place, and the decoder needs far less memory than networks that pass whole feature maps across.
SegNet was built for road-scene understanding on limited hardware. Memory-efficient decoding still matters for embedded segmentation on cars, drones and robots.
- 1. SegNet's decoder uses…
- 2. Each pooling index takes about…
- 3. SegNet was designed for…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Max pooling with indices: for the 2 × 2 window [[1, 5], [3, 4]] the output is 5 and the index is 1 (top right). Over a 4 × 4 map, the pooled values are [[5, 8], [9, 3]].
- Max-unpooling:
- place each pooled value at its recorded position and put zeros elsewhere;
- the 4 × 4 result sums to 5 + 8 + 9 + 3 = 25;
- after one level, a quarter of positions hold values; after four levels, 1/256.
- Memory:
- an index needs ⌈log₂ 4⌉ = 2 bits;
- passing the full pre-pooling map instead needs 4 values × 32 bits per pooled cell, 64 times more;
- for a 360 × 480 image with VGG’s 5 stages: 1.25 MB of indices against 80.4 MB of feature maps.
- Architecture:
- encoder: VGG-16’s 13 convolutional layers (fully connected layers removed);
- decoder: mirrors it with unpooling, convolutions and BN;
- a final softmax over classes per pixel, for example 11 road-scene classes in CamVid.
- 1. Bits per 2 × 2 pooling index:
- 2. Memory ratio of full maps to indices:
- 3. After 4 poolings, share of positions surviving:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.SegNet in code
Exercise 1.
- Pooling with indices and unpooling restored each maximum to its original position, with zeros elsewhere.
- The memory comparison gave 1.25 MB against 80.4 MB for a 360 × 480 image.
Practice.
- PyTorch has
nn.MaxPool2d(2, return_indices=True)andnn.MaxUnpool2d(2). - The decoder’s convolutions after each unpooling are essential: they turn sparse maps into dense features.
- Class-balanced loss (median frequency balancing) helps rare classes such as poles and signs.
- SegNet has fewer parameters than FCN-8s (about 29 M against 134 M) and no fully connected layers.
- Bayesian SegNet adds Monte Carlo dropout to estimate per-pixel uncertainty, useful for safety-aware driving.
pool = nn.MaxPool2d(2, return_indices=True); unpool = nn.MaxUnpool2d(2)
x, idx = pool(enc_features) # encoder: remember where the maxima were
y = unpool(dec_features, idx) # decoder: put values back, zeros elsewhere
y = decoder_conv(y) # trainable convolutions densify the sparse map- 1. PyTorch unpooling layer:
- 2. Median frequency balancing helps…
- 3. Bayesian SegNet estimates uncertainty with…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
What the indices preserve. Max pooling discards positions within each window. Its output alone cannot say whether an edge was on the left or right of a 2 × 2 cell, and after several levels the uncertainty grows to 2ᴸ pixels. Pooling indices record exactly this lost information, so the decoder can place boundaries precisely.
What they do not preserve. Only the maximum of each window survives, so an unpooled map is sparse: after L levels it holds one value per 2ᴸ × 2ᴸ block. Exercise 2 shows the two extremes:
- unpooling keeps precision (1.0) but loses recall (0.065 after four levels);
- interpolation keeps recall but loses precision.
SegNet’s decoder convolutions learn to fill in, combining precise placement with dense output.
Trade-offs against U-Net and FCN.
- U-Net passes whole feature maps, which is more information but 64 times more memory at each skip.
- SegNet passes positions only, which is memory-efficient and good at boundaries but carries no encoder features to the decoder.
- The SegNet paper reported that FCN-style decoders storing encoder features were more accurate when memory was not a constraint.
- 1. Pooling indices preserve…
- 2. An unpooled map is…
- 3. Without memory limits, storing encoder features was…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.What does unpooling keep?
History.
- M. Zeiler and R. Fergus (2014) used switches for unpooling in their deconvnet visualisations (E8-3).
- V. Badrinarayanan, A. Kendall and R. Cipolla introduced SegNet (arXiv 2015; IEEE TPAMI 2017), for road scenes (CamVid) and indoor scenes (SUN RGB-D).
- A. Kendall, V. Badrinarayanan and R. Cipolla (2017) introduced Bayesian SegNet.
Exercise 2. The images are 50 thin-line images (64 × 64; lines like poles or wires). Each is encoded with four 2 × 2 max poolings and decoded back to full size three ways: max-unpooling with the stored indices, nearest-neighbour upsampling, and bilinear upsampling. We measure precision (share of lit pixels on a line), recall (share of line pixels lit) and IoU:
| decoder upsampling | precision | recall | IoU |
|---|---|---|---|
| max-unpooling with indices (SegNet) | 1.000 | 0.065 | 0.065 |
| nearest-neighbour | 0.063 | 1.000 | 0.063 |
| bilinear | 0.062 | 0.998 | 0.062 |
- Unpooling is perfectly placed but sparse: every restored value sits on a line, but only one pixel per 16 × 16 block survives.
- Interpolation is complete but misplaced: it lights whole blocks.
- With fewer pooling levels the trade-off softens. With one level, recall 0.51 against precision 0.49; each extra level halves the weaker quantity.
- Neither is a segmentation on its own. SegNet’s trainable decoder convolutions turn the precisely placed sparse maps into dense, sharp outputs.
SegNet in AI, robotics and aerospace
- Road scenes: SegNet was designed for driving (lanes, pedestrians, poles), and Bayesian SegNet’s uncertainty maps flag unreliable pixels.
- Embedded memory: index-based decoding suits small GPUs and accelerators on robots and drones.
- Thin structures: precise unpooling helps keep poles, wires and markings in place, though they still need a strong decoder.
References
- V. Badrinarayanan, A. Kendall, R. Cipolla (2017). “SegNet: a deep convolutional encoder-decoder architecture for image segmentation.” IEEE TPAMI 39(12).
- A. Kendall, V. Badrinarayanan, R. Cipolla (2017). “Bayesian SegNet: model uncertainty in deep convolutional encoder-decoder architectures for scene understanding.” Proc. BMVC.
- M. D. Zeiler, R. Fergus (2014). “Visualizing and understanding convolutional networks.” Proc. ECCV.