Quiz: pretext tasks and masked image modelling
Before this unit: Day 41: Modern deep learning; Day 37: Training networks in practice.
See also: Denoising and what you may measure (day 5).
Short questions on learning features from unlabelled images. Try each on paper first, then open the answer.
Q1. What is the difference between a pretext task and a downstream task?
Which one has free answers?
The pretext task is made up so that its answers come with the images (the rotation we applied, the patches we hid); it is only a means to learn features. The downstream task is the real one (classify, segment), trained afterwards on those features with few labels.
Q2. Why is predicting the rotation of an image a poor pretext task for fluorescence images of cells?
Is there an “up” in a field of cells?
Cells have no natural orientation, so the rotation can only be read from artefacts: an illumination gradient, a scale bar, the camera’s pattern. The network learns those shortcuts instead of anything about cells.
Q3. Masked autoencoders hide 75 % of the patches. Why not 10 %?
How would you fill a small hole surrounded by visible pixels?
With 10 % hidden, almost every hidden patch is surrounded by visible ones and can be filled by interpolation: the task is too easy and teaches little. With 75 % hidden the network must know what the images look like to fill the gaps. (It also makes the encoder cheaper: it sees only a quarter of the patches.)
Q4. Why are the reconstructions of a masked autoencoder blurry?
What prediction minimises a squared error when several fillings are plausible?
With a squared error the best prediction is the average of the plausible fillings (the conditional mean), which is smooth. Sharp details that cannot be predicted are averaged away.
Q5. After pretraining, which part of a masked autoencoder do you keep, and how do you check that it is useful?
Reconstructions are a by-product.
Keep the encoder, throw away the decoder. Check the features: train a linear probe (or use k nearest neighbours) on frozen features with a few labels and measure the accuracy on held-out data.
Q6. In the demo, a linear model learnt from other images beats interpolation on synthetic nuclei but loses on the micrograph. Give one reason.
What is under a hidden patch of grainy texture?
The micrograph’s fine texture cannot be predicted from the surroundings, so a local average is already the best simple guess, and one global linear model of very varied windows adds wrong structure. The nuclei have strong shared structure (blobs with sharp outlines) that the model can continue across a hole.
Q7. (math) Show that the prediction \hat y minimising \mathbb E[(\hat y - y)^2] is \hat y = \mathbb E[y].
Differentiate with respect to \hat y.
\frac{d}{d\hat y}\mathbb E[(\hat y - y)^2] = 2(\hat y - \mathbb E y) = 0 gives \hat y = \mathbb E y; the second derivative is 2 > 0, a minimum. The remaining error is \mathrm{Var}(y).