Transfer learning and fine-tuning

core 10 minrepresentationtransfer-learningfine-tuning

Builds on:Convolutional neural networks

The idea

Networks trained on large datasets learn representations whose early and middle layers are strikingly generic — edges and textures in vision, morphology and syntax in language — while only the later layers commit to the pretraining task. Transfer learning is the decision to buy those generic layers instead of re-learning them: start from pretrained weights, and spend your scarce labels only on what is genuinely task-specific.

Two regimes, really a spectrum:

Choosing along two axes — data size and domain similarity:

Similar domainDifferent domain
Small datafreeze; train headfreeze early layers; tune later ones carefully
Large datafine-tune all, low LRfine-tune all; benchmark vs scratch

The standard safe recipe when unfreezing: train the head first (frozen backbone), then unfreeze top-down with discriminative learning rates (each earlier block ~2-10x lower), warmup, early stopping. Modern LLM-scale practice pushes the same logic further with parameter-efficient fine-tuning: LoRA freezes WW and learns a low-rank ΔW=BA\Delta W = BA (rank 4-64, ~0.1-1% of parameters), mergeable into WW after training — adaptation without touching, or storing copies of, the base model.

Worked example

The "500 labeled images, 5 classes" scenario, in numbers, with an ImageNet-pretrained ResNet-50 (25.6M parameters, 2048-d final features):

StrategyExpected behavior with 500 imagesHow to judge it
Small network from scratchmay work with strong augmentation; high variancekeep as a domain-matched baseline
Fine-tune all of ResNet-50 immediatelyhigh overfitting/forgetting riskonly retain if repeated validation supports it
Unfreeze last stage + headmore adaptation, more variancecompare after the frozen probe plateaus
Freeze backbone; train 5-way headlow-variance starting point on pretrained featuresrecommended first experiment, not a theorem

The head-only row is a 5-class logistic regression on 2048-d pretrained features. It is a sensible low-variance starting point, not something that 500 labels automatically guarantee. Multiply the data with augmentation (flips, crops, color jitter), pick the stopping epoch by validation loss, and use 5-fold cross-validation for reporting, since one 100-image validation fold has a standard error of several percent on its own. Only if the probe plateaus below target: unfreeze the final stage (~15M of the 25.6M parameters sit there) at one-tenth the head LR for a few epochs — the classic two-phase recipe.

Cheat sheet