Lessons › Chapter 9: Computer vision
Transfer learning
transfer learning starts from a network someone already trained on a huge photo collection. Its early layers already detect edges, textures and parts, and those are useful for almost any picture. Freeze them.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
Only 800 photos
Brightbank has just 800 labeled ID photos, nowhere near enough to train a vision network from scratch.
Training from scratch is expensive
Big vision networks learn from millions of labeled photos and lots of computing time. You probably have a few hundred photos of the thing you care about.
Reuse a trained network
transfer learning starts from a network someone already trained on a huge photo collection. Its early layers already detect edges, textures and parts, and those are useful for almost any picture. Freeze them.
Swap in a new head
Replace the last layer with a small new one for your classes, say “healthy leaf” or “sick leaf”, and train only that on your few hundred photos. It learns quickly because the hard work is already done.
Fine-tune if you can
With a bit more data, unfreeze the top layers too and train them gently with a small learning rate. This fine-tuning adapts the network’s higher-level features to your specific images.
In real life: spotting crop disease from a phone
Apps that spot plant diseases from a phone photo are often built this way: start from a network trained on everyday photos, then teach a new head with a few thousand labeled leaf pictures. A small team can build it in weeks.
Quick check: In transfer learning, which part is usually trained on your small dataset?
- The new head (the last layers) (correct)
- The whole network, from scratch
- Nothing at all
The pre-trained base is frozen; you train the new head (and maybe the top layers).
Pseudocode
base = a network trained on millions of everyday photos freeze base # keep what it already knows head = a new small output layer for your classes train only the head on your few hundred photos # optional: unfreeze the top layers and fine-tune gently
Key terms
- transfer learning
- Starting from a network already trained on a big task and adapting it to yours.
- fine-tuning
- Continuing to train a pre-trained model gently on your own data.
In the news
Recent models and papers that build on this idea: