Finetuning 1

Reusing a pre-trained encoder: frozen features, head replacement, expected normalization

In this chapter, you will learn to

Tools: PyTorch, torchvision

6 exercises

Each exercise is graded automatically, in your browser. The full statements are available once you have an account.

  1. 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…

  2. 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…

  3. 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…

  4. 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…

  5. 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 [0,1][0, 1] then normalized channel by…

  6. 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…