🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Transfer Learning — Pre-trained Models Complete Guide

Deep LearningTransfer Learning🟢 Free Lesson

Deep Learning

Transfer Learning — Stand on the Shoulders of Giants

Learn how to leverage pre-trained models to solve new problems with less data and compute.

  • Knowledge transfer — reuse learned features from large models
  • Fine-tuning — adapt pre-trained weights to your task
  • Data efficiency — achieve great results with small datasets

If I have seen further, it is by standing on the shoulders of giants.

Transfer Learning — Complete Guide

Transfer learning reuses a pre-trained model on a new task, dramatically reducing data and training requirements. This is now the default approach in modern ML — training from scratch is the exception.


Why Transfer Learning?

Transfer Learning vs Training from ScratchTraining from ScratchData Required1M+ labeled imagesComputeWeeks on GPU clusterCost100K+Overfitting RiskVery high with small dataAccuracy (small dataset): 60-70%Only practical when you have:massive data + compute budgetTransfer LearningData Required100-10K labeledComputeHours on single GPUCost100Overfitting RiskLow (regularized by pre-trained weights)Accuracy (small dataset): 90-95%+The default approach in modern ML.Train from scratch only when necessary.

Why the Trade Is Worth It

Training a vision model from scratch on a million labelled images used to be the only reliable route to strong accuracy, and it still is when the data and the compute budget both exist. Most teams have neither. A pre-trained network has already spent millions of gradient steps learning to recognise edges, textures and object parts, and those features are not tied to the dataset they were learned from. Reusing them turns a job that needed a GPU cluster for weeks into one that finishes in hours on a single card.

The figures in the diagram are representative rather than exact, but the shape of the gap is consistent. Given a few hundred examples per class, a pre-trained backbone plus a small head usually lands twenty to thirty points above the same architecture trained from random initialisation. Overfitting risk falls as well, because the frozen weights act as a strong prior: the model cannot memorise fifty images per class if it is only permitted to move a few thousand parameters. The practical consequence is that data collection effort, which is the expensive part of most projects, can be cut by an order of magnitude without giving up the accuracy a larger labelled set would have bought.


Feature Hierarchy in Pre-trained Models

What Pre-trained Models Learn (Feature Hierarchy)Early LayersEdges, colors, simple textures→ Universal — works for any vision taskFreezeMiddle LayersPatterns, object parts, combinations→ Mostly transferable — slight task-specific tuningFine-tune (small LR)Deep LayersObject-level, semantic concepts→ Task-specific — fine-tune theseFine-tune (small LR)Final LayerTask-specific output (1000 ImageNet classes)→ Replace — train new classification headReplaceKey insight: Early features (edges, textures) are universal. Deep features are task-specific. This is why transfer learning works.

Why the Early Layers Transfer

The hierarchy above settles which parts of a network are safe to reuse. Early filters respond to edges, colour gradients and simple textures, and those statistics are close to identical whether the source images were pets and the destination images are chest X-rays. Middle layers assemble edges into object parts and textures into patterns, which still transfers well across related tasks. Deep layers and the classification head are where the source label space has been written into the weights, so that is the section you replace.

This becomes a freezing decision in code. Setting requires_grad to false on the backbone and attaching a new head means only the head receives gradients, and the forward pass effectively becomes a cached feature extractor. When the destination domain has visibly moved, unfreezing the final block and giving it a much smaller learning rate recovers most of the accuracy that full freezing gives away, because that block is the first place where source and destination statistics diverge.

python
import torch
from torchvision import models

model = models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1)

for param in model.parameters():
    param.requires_grad = False          # freeze the whole backbone

model.fc = torch.nn.Linear(2048, 7)      # new head for our 7 classes

trainable = sum(p.numel() for p in model.parameters() if p.requires_grad)
total = sum(p.numel() for p in model.parameters())
print(f"trainable {trainable:,} / {total:,}")   # 14,343 / 25,557,032

optimizer = torch.optim.AdamW(model.fc.parameters(), lr=1e-3)

Transfer Learning Strategies

Transfer Learning StrategiesStrategy 1: Feature ExtractionPre-trained layers (FROZEN)New classification head (TRAINABLE)• Fastest (only head trains)• Least overfitting risk• Use when: small dataset, similar domain to pre-trainingBest for: quick baselineStrategy 2: Partial Fine-tuningTop layers (SMALL LR)Bottom layers (FROZEN)• Moderate speed• Good balance of speed/quality• Use when: medium dataset, moderate domain shiftBest for: most practical casesStrategy 3: Full Fine-tuningALL layers (SMALL LR)New head (NORMAL LR)• Best performance• Slowest, most compute• Use when: large dataset, different domainBest for: maximum accuracyDecision MatrixSmall data + Similar domain → Feature extractionSmall data + Different domain → Fine-tune top layersLarge data + Similar domain → Full fine-tuneLarge data + Different domain → Fine-tune or train from scratch

Choosing Between the Three Strategies

The decision matrix compresses the choice into two questions: how much labelled data exists, and how far the destination domain sits from the pre-training domain. When both answers are favourable, feature extraction wins, because with a frozen backbone it is almost impossible to overfit and the training loop is short enough to sweep hyperparameters freely. When the data is small but the domain has moved — natural photographs to satellite imagery, product photos to infrared, formal news text to informal support tickets — freezing everything leaves useful capacity idle, so unfreeze the top block and fine-tune it at a tenth of the head learning rate.

With abundant data and a genuinely new domain, full fine-tuning pays for its cost, and training from scratch becomes defensible only when no pre-trained model exists for that modality at all. A cheap way to settle the question empirically is to run all three strategies on the same split for one epoch each and compare validation accuracy per minute of wall-clock time. The strategy that wins that comparison almost always wins after a full training run, and the comparison costs less time than a single long run that turns out to be the wrong one.


Implementation


When to Use Transfer Learning


Catastrophic Forgetting


Common Mistakes & How to Avoid Them

Common Mistakes

Loading a pre-trained checkpoint but forgetting to freeze it, then destroying the learned weights in the first few steps

Fix: Set requires_grad to false on every backbone parameter before building the optimizer, and assert that the trainable parameter count matches your expectation

Fine-tuning the whole network at the same learning rate used for the freshly initialised head

Fix: Use discriminative rates: roughly 1e-5 for unfrozen backbone layers and 1e-3 for the new head, so early features move slowly and task features move quickly

Keeping the source preprocessing at inference time after changing the destination domain

Fix: Match resize, crop and normalisation to the checkpoint you actually loaded, and re-check a handful of predictions before trusting validation scores


Key Takeaways


What to Learn Next

-> BERT Apply transfer learning in NLP.

-> GPT Architecture Explore large language models.

-> Transformers Master the foundation of modern AI.

-> CNNs Learn about computer vision models.

-> Fine-tuning LLMs Adapt large models to your specific needs.

-> Training Deep Networks Master optimizers and regularization.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-17

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Machine Learning Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement