DeepLLM Quiz
Neural Network Architectures

Semantic segmentation: labelling every pixel, and how to up-sample

10 questions on per-pixel classification, output shapes, why the naive approaches are costly, down-sampling and up-sampling and the idea of unpooling.

  • 10 questions
  • Stopwatch
  • Instant feedback

Shown publicly with your score. Don’t use your full real name.

Sample questions

Play now ↑

Answers stay hidden. Start the quiz to play them.

  1. Sample 1

    Why is it wasteful to classify a patch around every pixel one at a time?

    • Neighbouring patches overlap heavily, so the same calculations are repeated many times
    • Patches cannot be classified at all
    • The classifier can only see one patch in total
  2. Sample 2

    In the up-sampling analogue of average pooling, a single input value 7 is expanded into a 2 by 2 block of the output. What does the block contain?

    • Four copies of 7
    • 7 in one cell and 0 in the other three
    • Four random numbers

How it works

  • One question per screen. An answer is final once sent.
  • You see right away whether you were right, with a short explanation.
  • The stopwatch runs: on equal scores, the faster player ranks first.
  • Only your best attempt counts, so replaying is never risky.

About this quiz

A classifier says: this photograph contains a car. A detector says: there is a car in this rectangle. A segmentation network goes further and says: these exact pixels are car, these are road, these are sky and these are pedestrian. The result is an image-sized map in which every pixel carries a label, the kind of output needed to steer a vehicle, to outline a tumour in a scan or to cut a person out of a video call. Producing such a dense answer from a network that is built to compress information is an interesting design problem, and this quiz is about how it is solved.

You will start with the shape of the answer: an array with the same height and width as the input and one channel per class, from which a coloured label map can be drawn. You will then look at the most obvious ways of obtaining it and see why they disappoint. Classifying a patch around every pixel works but repeats enormous amounts of calculation. Keeping the full resolution in every layer avoids that waste but makes every layer expensive. A network that shrinks the picture, gaining channels as it goes, is far cheaper, so the natural idea is to compress first and then expand again to the original resolution.

The second half of the quiz is about the expanding. Pooling and strides throw away resolution, so we need operations that go the other way. The simplest ones are fixed rules, like the pooling operations: one copies each value across a block, and another places each value at a single position in a block and fills the rest with zeros. You will work through small cases of both, see why the second feels arbitrary, and meet the refinement that remembers where each maximum came from so that the value can be put back in the right place.

Common mix-ups include confusing segmentation with detection, assuming that a segmentation network outputs a single label, and forgetting that the output has one channel per class. Another is to assume that the only way of getting an image-sized output is to keep the full size throughout. Dense prediction is one of the most useful tasks in applied vision, and the compress-then-expand pattern behind it turns up in many other places, from models that restore noisy pictures to those that estimate depth at every pixel. Grasping the basic reason for it, that information is cheapest to process in a compact form but must be spread back over the image to be used, will help you read a great many architecture diagrams, and prepares you for the learned expanding layers and skip paths covered in the next quiz.

The quiz suits learners who know convolution and pooling and want to see how dense predictions are made, and practitioners who work with scenes or scans. There are 10 questions, each with an explanation, and it takes about four minutes.

Questions and answers

›How long does the quiz take?

About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. An explanation follows every answer, including the small unpooling examples.

›Do I need to know detection first?

No, although it helps to know that detection finds objects with boxes. Segmentation is a finer task, and the quiz explains it from the start. You should know what convolution and pooling do, which the earlier quizzes in the series cover.

›What is semantic segmentation?

It is the task of assigning every pixel of an image to one of a set of predefined classes, such as sky, grass, trees and buildings, or healthy tissue and diseased tissue. The output has the same height and width as the input, and it can be shown as an image in which each pixel is coloured according to its class.

›What does the output of a segmentation network look like?

It is an array with the same height and width as the input image and one channel for each class, holding the probability of each class at each pixel. Choosing the most probable class at each pixel gives the label map. The input has three colour channels, but the output has as many channels as there are classes.

›Why is the patch-per-pixel approach inefficient?

Classifying a patch centred on each pixel in turn means that neighbouring patches overlap almost completely, so the same calculations are done many times. The waste can be removed by arranging the calculation as a single convolutional network, whose fully connected layers are also convolutional, but a network that keeps full resolution throughout is still too costly.

›Why compress and then expand?

Shrinking the feature maps while adding channels keeps the network tractable and lets it extract high-level meaning. Then extra learnable layers transform the small internal representation back up to the original resolution. This is far cheaper than keeping the full image size in every layer, and it is the basis of the standard design.

›What are the fixed up-sampling rules?

One is the analogue of average pooling: each input value is copied into all the cells of the corresponding block of the output. Another, the analogue of max pooling, copies each input value into one cell of its block and sets the other cells to zero. Applying the matching pooling operation to the result recovers the original input in both cases.

›How can the position of the maximum be preserved?

By recording, during down-sampling, which cell in each block held the maximum value, and using the record in the matching up-sampling layer to put the non-zero value back in exactly that cell. The network then keeps some of the spatial detail that max pooling discards, instead of placing values arbitrarily.

More quizzes