Quiz: fine-tuning strategies
Before this unit: Transfer learning (previous unit); Day 43: Networks for cells and objects; Day 42: Learning without labels.
See also: Day 38: Evaluation and statistics.
Short questions on how to fine-tune. Try each on paper first, then open the answer.
Q1. Why should the new head get a larger learning rate than the pretrained layers?
Where does each start?
The head starts from random weights and has everything to learn; the pretrained layers are already good and should move only a little. One rate for all is either too slow for the head or too fast for the backbone.
Q2. What is catastrophic forgetting, and name two ways to limit it.
What happens to the old task while training on the new one?
Training on the new task overwrites the weights the old task needed, so the network gets much worse at the old task (in the toy from 98 % to about a third). Freeze layers, use small or layer-wise rates, add a penalty pulling the weights towards the pretrained ones, mix old examples into the batches, or train only added parts (adapters, LoRA) and keep the original weights.
Q3. A 1024 × 1024 weight matrix is changed with a rank-4 update BA. How many numbers are stored instead of the full change?
r(m + n) against mn.
4 \cdot 2048 = 8192 instead of 1{,}048{,}576: 0.8 %.
Q4. Why does LoRA start with B = 0?
What is W_0 + BA at the start?
Then BA = 0 and the network starts exactly as the pretrained one; training only adds a change. (A is random so that the gradient of B, which involves A\mathbf x, is not zero.)
Q5. The singular values of a weight change are 5, 4, 0.3, 0.2, 0.1 and smaller. Which rank would you choose for a low-rank update, and why?
Where is the knee?
Rank 2: the first two singular values carry almost all of the change (25 + 16 = 41 of about 41.14 in squared size; the relative error is about \sqrt{0.14/41.14} \approx 6 %); the rest is a small tail.
Q6. You want to adapt SAM to outline your cells. Which part do you fine-tune first, and why?
Heavy encoder, light decoder.
The light mask decoder: few weights (less overfitting with few annotated cells), the heavy encoder’s embeddings can be computed once per image and stored, and the general image features of the encoder are kept.