Quiz: segmentation networks

Short questions on encoder–decoders, U-Nets, per-pixel losses and evaluation. Try each on paper first, then open the answer. Dice = 2|P \cap G|/(|P| + |G|), IoU = |P \cap G|/|P \cup G|.


Q1. Why can a classification network with a dense last layer not simply be used to segment an image?

What does it output, and for which input size?

It outputs one set of class probabilities for the whole image, and its dense layer fixes the input size. A segmentation network must output one probability per pixel, for any image size: it has to be convolutional all the way, with a decoder that returns to full resolution.


Q2. What do the skip connections of a U-Net carry, and what goes wrong without them?

What did pooling throw away?

They copy the sharp, full-resolution feature maps of the encoder to the decoder. Without them the decoder only has the coarse bottleneck maps: it knows roughly where objects are, but boundaries and small objects come out blurred or misplaced.


Q3. Nuclei cover 3 % of the pixels. A network predicts “background” everywhere. What are its pixel accuracy and its Dice?

|P| = 0.

Accuracy 97 %, Dice 0 (no true positives). Accuracy rewards the large background class; Dice looks only at the objects.


Q4. Upsample (4, 8) by a factor 2 with nearest neighbour, then with a transposed convolution with stride 2 and kernel (\tfrac12, 1, \tfrac12).

Each input value stamps the scaled kernel, two positions apart.

Nearest: (4, 4, 8, 8). Transposed: 4 \cdot (\tfrac12, 1, \tfrac12) at positions 0–2 and 8 \cdot (\tfrac12, 1, \tfrac12) at positions 2–4: (2, 4, 2 + 4, 8, 4) = (2, 4, 6, 8, 4): linear interpolation between 4 and 8, with a half value at the far end.


Q5. A U-Net trained on images from one microscope gives Dice 0.95 on held-out images from it, and 0.6 on images from a new microscope. What is this called, and what would you do?

Training range.

Domain shift: the new images (brightness, noise, blur, stain) lie outside what the network has seen. Annotate a few images from the new microscope and add them to the training set (fine-tune), augment brightness and noise more strongly during training, and always test on images from the setting where the network will be used.


Q6. The U-Net gives a perfect mask of two touching nuclei. Why is the nucleus count still wrong?

Connected components of the mask.

A semantic mask only says “nucleus or not” per pixel: two touching nuclei form one connected component, which labelling counts as one object. They have to be split, for example with a “boundary” class, the distance transform and the watershed (days 13–15), or with a network that outputs separate objects (day 41).


Q7. (math) Soft Dice D = 2\sum p_ig_i/(\sum p_i + \sum g_i). A pixel outside the object (g_j = 0) has its probability p_j raised. Does D go up or down? Show it from the formula.

Only the denominator depends on p_j.

Down: with g_j = 0 the numerator does not change and the denominator grows, \partial D/\partial p_j = -2\sum_i p_ig_i/(\sum_i p_i + \sum_i g_i)^2 \le 0. False positives are penalised, and more strongly the better the overlap already is.