DEV Community

Devanshu Biswas
Devanshu Biswas

Posted on

Transfer Learning: Stand on a Pretrained Model

You don't have a million labeled images or a GPU farm — and you don't need them. Transfer learning lets you stand on a model someone else trained and reach high accuracy with a few examples in minutes. Here's the idea, visualized.

♻️ Race scratch vs transfer: https://dev48v.infy.uk/dl/day17-transfer-learning.html

The insight

The early layers of a trained network learn general features — edges, textures, shapes — that are useful for almost any vision task. Only the last layers are task-specific. So why relearn edges from scratch?

Two ways to do it

  • Feature extraction: freeze the pretrained backbone, replace the final classifier with a small new "head," and train only the head on your data. Fast, needs little data.
  • Fine-tuning: also unfreeze the top few backbone layers and train them at a low learning rate so you adapt without wrecking what they learned.

The demo races two accuracy curves: "from scratch" crawls up and plateaus low (not enough data); "transfer learning" starts high and climbs fast. Tweak the example count and freeze/fine-tune to see them respond.

Why it matters now

This is exactly why fine-tuning an open LLM works: a foundation model already learned language; you adapt it cheaply. Transfer learning is what makes deep learning practical for the rest of us.

🔨 Full recipe (load pretrained → freeze → new head → train → optionally fine-tune low-LR) on the page: https://dev48v.infy.uk/dl/day17-transfer-learning.html

Part of DeepLearningFromZero. 🌐 https://dev48v.infy.uk

Top comments (0)