Finetuning 1
Reusing a pre-trained encoder: frozen features, head replacement, expected normalization
In this chapter, you will learn to
- Reuse a pretrained network instead of starting from scratch
- Choose between frozen features and retraining part of the network
- Prepare data the way the model expects
Tools: PyTorch, torchvision
6 exercises
Each exercise is graded automatically, in your browser. The full statements are available once you have an account.
What this is for in real life
Nobody trains a vision model from scratch when they can recycle one. - What practitioners do first. torchvision and Hugging Face offer thousands of already trained models, downloaded in one line of code. Almost…
Filters instead of pixels
Your letter sorter from the previous problem works, but it dumbly compares pixels one by one. A slightly shifted or thicker digit fools the system. And indeed: the post office's new scanner does not always center the…
The full pipeline
The post office director wants a system that learns to classify digits automatically, instead of just comparing with known examples. You have a pipeline that turns each image into a feature vector (via…
Recycling a champion
You have classified images starting from scratch, but with little data, a network trained from scratch quickly hits a ceiling. The pros' reflex: recycle an already-trained model. Take a ResNet18 pre-trained on…
Lesson: ImageNet normalization
A pretrained model did not learn on "images" in general: it learned on tensors prepared in one precise way. torchvision models trained on ImageNet receive images converted to then normalized channel by…
The shortcut
You are a data scientist at a hospital. You must classify chest X-rays into 3 categories (healthy, pneumonia, tuberculosis). Problem: you only have 100 annotated images. Training a full neural network from scratch…