Path: blob/master/notebooks/book1/19/finetune_cnn_torch.ipynb
2300 views
Please find jax implementation of this notebook here: https://colab.research.google.com/github/probml/pyprobml/blob/master/notebooks/book1/19/finetune_cnn_jax.ipynb
Fine-tuning a resnet image classifier to classify hotdog vs not-hotdog
We illustrate how to fine-tune a resnet classifier which has been pre-trained on ImageNet. Based on sec 13.2 of http://d2l.ai/chapter_computer-vision/fine-tuning.html. The target dataset consists of 2 classes (hotdog vs no hotdog), and has 1400 images of each. (This example is inspired by Season 4, Episode 4 of the TV show Silicon Valley.
Dataset
We show the first 8 positive and last 8 negative images. We see the aspect ratio is quite different.
We use data augmentation at train and test time, as shown below.
Model
The final layer is called fc, for fully connected.
Fine tuning
In D2L, they call their training routine train_ch13, since it is in their chapter 13. We modify their code so it uses a single GPU, by commenting out the DataParallel part.
We update all the parameters, but use a 10x larger learning rate for the fc layer.