Transfer Learning
CSC3104 · Lab

Freeze or fine-tune?

Choose a transfer-learning strategy for four real situations, then count exactly how many ResNet-50 parameters you'd be training.

  1. 1 · Predict0/1
  2. 2 · Experiment0/2
  3. 3 · Explain0/1
  4. 4 · Code it0/2
  5. 5 · Challenge
  6. 0/4 tasks done

Predict first

Commit to a guess before you touch anything. Being wrong here is how it sticks.

A linear probe on 2,048-d features for 10 classes (with bias). Trainable parameters?

Experiment

Move the controls and watch the outputs. Goals tick off automatically when you reach them.

Freeze or fine-tune?

Recommended
Freeze the backbone, train a new head
Little data + familiar features → a linear probe avoids overfitting.
model = resnet50(weights="IMAGENET1K_V2")
for p in model.parameters(): p.requires_grad = False
model.fc = nn.Linear(2048, num_classes)
opt = AdamW(model.fc.parameters(), lr=1e-3)

How many parameters train?

ResNet-50: ~23.5 M backbone parameters; 2,048-d features into the head.

Trainable
23,518,277
Frozen
0
% trainable
100.00%

Explain it

Put what you saw into words. This is what the exam will ask you to do.

What is catastrophic forgetting, and when should you freeze the backbone versus fine-tune everything?

Code it

Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.

Pythonwarm-up

How much will actually train?

Write trainable(num_classes, unfrozen) → number of trainable parameters when the new head is nn.Linear(2048, num_classes) (with bias) and unfrozen is a list of stage names that are also trained. Also share(num_classes, unfrozen) → trainable / total (backbone + head).

Ctrl/⌘ + Enter to run

Challenge

Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.

Linear Probe Trainable Weights

You replace ResNet-50's final layer with nn.Linear(2048, 5) and freeze the entire backbone. How many trainable parameters are there?