skip to content

Adapting a Pretrained Model

Moving a pretrained network onto a new task and a new distribution: how much to unfreeze, how gently to step, what the model quietly forgets, and what to do when the target carries no labels.

on this pageshow

explore

questions

17

What is catastrophic forgetting when a pretrained network is fine-tuned on a new task?

level: juniorimportance: must knowfreq 58%

answer

  1. learning B costs you A
  2. the loss has no term for old data
  3. shared weights, myopic optimizer
  4. new head, new gradients, drifted features
  5. old task metrics nobody is watching

basics

~20 s

Catastrophic forgetting is the sharp drop in a network's performance on its original task after it is trained on a new one. Fine-tuning minimises only the new task's loss, so the shared weights drift away from the old solution.

solid answer

~50 s

Catastrophic forgetting is what happens when you keep training a network on task B and its accuracy on task A collapses, often within a few hundred steps. The cause is not mysterious: gradient descent is minimising a loss computed only on task B's data, and nothing in that objective references task A. Every parameter is shared, so the optimizer is free to move weights out of the region where task A's loss was low as long as that lowers task B's loss. A warehouse pick-and-place policy fine-tuned for a new suction gripper can end up unable to run the parallel-jaw task it shipped with, even though nobody changed the parallel-jaw code. It is worst when the two tasks share a backbone but differ in output space or input statistics, and when you train for many epochs at a step size large enough to move the pretrained features rather than just the head.

go deeper

for a junior

Be able to state the definition in one sentence and name the cause: training minimises only the new task's loss, and the weights are shared. Know that the old task's metrics have to be measured or the regression is invisible.

for a middle

Explain the optimization view — no term in the objective references the old data, so nothing resists moving out of the old low-loss region. Distinguish representation drift from a re-aimed output head, and say how you would tell them apart.

for a senior

Show that you expect it and instrument for it. Talk about which factors set the severity — task distance, how many layers move, how long you train, how many adaptation stages have stacked up — and about the retained evaluation that catches it before release.

for a principal

Own the position that any repeatedly adapted model needs a forgetting budget as an explicit release criterion, not a debugging afterthought. Be ready to argue when accepting the loss on a retired capability is the right call versus paying to retain it.

## The phenomenon A network is trained on task A until it performs well. Training then continues on task B — new labels, new data, or simply a newer slice of the same stream. Performance on B rises as expected. Performance on A, which nobody is measuring because A's data is no longer in the loop, falls hard. That collapse is **catastrophic forgetting**: the loss of previously acquired capability caused by learning something new in the same set of weights. The word *catastrophic* is doing real work. Forgetting in a neural network is not the slow decay a person experiences; it can take a network from 0.91 recall to below 0.5 on the old task inside a single epoch of the new one. ## Why it happens Think about what the optimizer is actually asked to do. During fine-tuning the objective is the average loss over the **new** task's batches. There is no term in that objective that mentions the old data, so there is no force at all resisting movement away from the old solution. The old solution was one point in a large region of weight space where task A's loss is low; the new gradient points wherever task B's loss falls fastest, and that direction is essentially unrelated to A's low-loss region. Three structural facts make it worse: - **The parameters are shared.** A single backbone encodes features for both tasks. There is no partition of weights reserved for A, so any update that helps B may overwrite a feature A depended on. - **The objective is myopic.** Stochastic gradient descent optimises the current batch's loss. It has no memory of the loss surface it came from, and no notion that some directions are cheap for B but expensive for A. - **The output layer usually changes.** Adapting to a new label set typically means a fresh, randomly initialised head. Early in training that head produces large, badly aimed gradients that propagate into the backbone, and if the old head was discarded the old task's predictions are gone by construction, not merely degraded. ## Two distinguishable failures It is worth separating **representation drift** from **head drift**, because they are diagnosed and repaired differently. - *Head drift*: the backbone still encodes everything the old task needed, but the classifier on top has been re-aimed at the new labels. In a class-incremental setup, where each stage introduces new classes and only those classes appear as positives, the final layer picks up a strong recency bias — logits for recently seen classes systematically outrank older ones. - *Representation drift*: the features themselves have moved, so the information the old task needed is no longer linearly available. A cheap way to tell them apart is to freeze the current backbone and fit a fresh linear classifier on old-task data. If that probe recovers most of the old performance, the features survived and the head was the casualty. If it does not, the representation itself has been overwritten. ## Where the severity comes from Forgetting is not a constant; it scales with how far training is allowed to move the weights and how far apart the tasks are. - **Distance between tasks.** Two tasks that need similar features interfere less. A new suction-gripper skill that reuses the same visual features as the old parallel-jaw skill damages less than one that needs an entirely different notion of graspability. - **How much of the network moves.** The more layers are unfrozen and the larger the steps, the more the pretrained features can be displaced. Lower layers, which encode generic structure, typically drift less than the task-specific upper layers, partly because their gradients are smaller and partly because generic features remain useful for the new task. - **How long training runs.** Forgetting compounds with steps taken on the new distribution, so a long fine-tune on a small new dataset is a common way to destroy a good backbone. - **Sequence length.** Under repeated sequential adaptation — five stages, then ten — the earliest stage is usually the worst hit, because it has had the most subsequent updates to survive. ## What it is not Two confusions are worth naming. First, forgetting is **not** overfitting. An overfit model has memorised the training set of the task it is being trained on; a model that has forgotten may generalise perfectly well on the new task while having lost a different one. They can occur together, but neither implies the other. Second, forgetting is **not** literal erasure. The weights still carry a great deal of old-task structure, which is why old performance is often partially recoverable from a small amount of old data far faster than it was originally learned. That partial recoverability is exactly what the standard mitigations exploit: keeping a slice of old data in the training stream, or adding an explicit penalty that makes the parameters the old task relied on expensive to move. ## The practical consequence Because the new-task metrics look healthy the whole time, forgetting is invisible unless you deliberately keep measuring the old task. Any pipeline that adapts a model repeatedly needs a retained evaluation set from the original task, scored on the same cadence as the new-task validation set, or the regression ships.

  • Is catastrophic forgetting the same thing as overfitting the new task?
    No. Overfitting means the model memorises its current training set and generalises poorly on that same task. Forgetting means performance on a different, earlier task collapses, and it can happen while the new task generalises well. They have different causes and different fixes, though a long, aggressive fine-tune on a small dataset tends to produce both at once.
  • Which parts of a network tend to forget most, and why?
    The task-specific upper layers and the output head. Lower layers encode generic structure that remains useful for the new task, so their gradients are smaller and they drift less. The head is often replaced outright for a new label set, and a freshly initialised head also sends large early gradients back into the backbone, which is what damages the features.
  • If the old task's data is gone, is the old capability permanently lost?
    Usually not entirely. The weights still carry much of the old structure, so a modest amount of old data restores old performance far faster than the original training did. That is evidence the capability was buried rather than erased. Without any old data at all you are limited to methods that constrained the parameters before the new training began.

Overwriting a whiteboard for a new meeting: nothing forbids using the space where yesterday's diagram was, because the only thing being optimised is today's diagram.

saying these in an interview costs you the question

  • Calls it overfitting to the new task
  • Thinks the network literally erases stored memories
  • Believes a low new-task loss proves nothing was lost
  • Assumes only the output head can be affected
  • Says it only happens with a bad learning rate

context

open as a page

In unsupervised domain adaptation, what is covariate shift and why does it hurt a trained network?

level: juniorimportance: must knowfreq 66%

basics

~20 s

Covariate shift means the input distribution moves from source to target while the rule mapping input to label is unchanged. The network was fitted where source data lived, so target inputs land where its decision boundary was never pinned down.

open as a page

Why is the fine-tuning learning rate for a pretrained network far smaller than its pretraining rate?

level: juniorimportance: must knowfreq 72%

basics

~20 s

Pretraining already puts the weights in a good region, so fine-tuning only needs small corrections. A large step moves every weight far enough to destroy the learned features, and a small target dataset cannot rebuild them.

open as a page

How do you replace a pretrained model's 1000-class head for a 7-class task?

level: juniorimportance: must knowfreq 66%

basics

~20 s

Discard the old output layer and attach a new, randomly initialised one with seven outputs, keeping the layers beneath it. The old head maps to the wrong label set, so none of its weights are reusable.

open as a page

With 800 labelled chest radiographs and a natural-image backbone, do you freeze or fine-tune?

level: middleimportance: must knowfreq 72%

basics

~20 s

Fine-tune part of it. 800 examples cannot safely update a whole backbone, but radiographs sit too far from natural photos for frozen top-layer features to work, so unfreeze the last stage and train a new head.

open as a page

How would you prove a pretrained backbone helped rather than caused negative transfer?

level: middleimportance: must knowfreq 52%

basics

~20 s

Negative transfer means a pretrained start leaves you worse off than starting cold. The only proof is a control run: the same architecture trained from scratch on the same target data, under a matched budget and equal tuning effort.

open as a page

How does replaying a small buffer of source examples reduce catastrophic forgetting?

level: middleimportance: should knowfreq 44%

basics

~20 s

Interleaving a small sample of the original task's data into every batch puts an old-task term back into each gradient. The optimizer can no longer lower the new loss at unlimited cost to the old one.

open as a page

In domain adaptation, why does re-estimating normalization statistics on target data help?

level: middleimportance: should knowfreq 45%

basics

~20 s

A network that normalizes with dataset-level means and variances carries constants measured on source data. Recomputing them from unlabelled target batches re-centres and re-scales every layer's activations into the range later layers expect, with no labels and no gradient steps.

open as a page

Why train a fine-tune's randomly initialised head with the pretrained backbone frozen first?

level: middleimportance: should knowfreq 52%

basics

~20 s

A fresh head predicts almost randomly, so its loss gradient is large and, seen from the backbone, close to noise. Freezing the backbone for the first epochs lets the head reach sensible outputs before any pretrained weight moves.

open as a page

How do you detect catastrophic forgetting while adapting a model to a new task?

level: seniorimportance: should knowfreq 46%

basics

~20 s

Keep a frozen evaluation set from the original task and score it on the same cadence as the new task's validation set. Forgetting shows up as a falling retained-source score, so make it a release gate.

open as a page

Under domain shift, why is a network's confidence a poor filter for target pseudo-labels?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Softmax confidence is not a calibrated probability, and shift makes it worse: a network stays confident where it is wrong. A fixed high threshold then keeps the most source-like, easiest examples, skewing the pseudo-label set toward classes the model already handles.

open as a page

A frozen backbone's features drift between epochs even though no weight gets a gradient — why?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Normalization layers hold running mean and variance estimates that are state, not learned parameters. Blocking gradients does not stop them: in training mode the forward pass keeps re-estimating them from the new domain's batches, so the outputs move.

open as a page

Negative transfer can come from a domain gap or a source-task mismatch — how do you tell which?

level: seniorimportance: should knowfreq 38%

basics

~20 s

A domain gap means the target inputs look statistically unlike the source data. A source-task mismatch means the source objective learned invariance to the very signal the target needs. Ask what the source loss rewarded, and what it deliberately ignored.

open as a page

How does elastic weight consolidation protect a network against catastrophic forgetting?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

Elastic weight consolidation adds a quadratic penalty pulling every parameter toward its old-task value, scaled by that parameter's Fisher information. Weights the old task depended on become stiff, while unimportant ones stay free to fit the new task.

open as a page

How does a gradient-reversal layer make a network's features domain-invariant?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

A domain classifier trained to tell source from target sits on the shared features. The gradient-reversal layer passes activations through unchanged but negates the gradient going back, so the feature extractor learns to defeat it while the task head keeps features useful.

open as a page

In layer-wise discriminative fine-tuning, why does the bottom block get a much smaller rate than the head?

level: seniorimportance: nice to knowfreq 34%

basics

~20 s

Depth decides how much a layer must change. Bottom blocks hold generic features that transfer almost unchanged and should barely move, while upper blocks are task-specific and the head is random, so rates rise geometrically from bottom to top.

open as a page

When does a smaller model trained on more in-domain data beat fine-tuning a large pretrained backbone?

level: principalimportance: nice to knowfreq 29%

basics

~20 s

When target labels are plentiful and the domain is far from the source. Pretraining supplies a prior worth most when data is scarce; with enough in-domain examples a small model learns better-suited features and costs less to serve.

open as a page