Classification with Transfer Learning
CIFAR10 classification with transfer learning on Inception V3.
In this task, you should train Inception V3 with pytorch using transfer learning to classify CIFAR10 dataset.
Load the CIFAR10 dataset bellow. You can use either torchvision.datasets.CIFAR10
or sklearn.datasets.fetch_openml()
or any other way to load the dataset.
Instantiate Inception V3 model (pretrained on imagenet) from torchvision
's model zoo.
Imagenet has 1000 classes, but CIFAR10 has 10. So, the decider layers of the model must be changed so that we can use the model for CIFAR10. Therefore, adapt net.fc
and net.AuxLogits.fc
with CIFAR10.
In order to apply transfer learning, freeze all layers except the deciders. Freezing consist of disabling optimization by disabling grad calculation. Also in batch normalization layers, updating mooving average and variance must be disabled. Note that you must later filter out the frozen parameter for optimizer.
Create the optimizer filtering out freezed parameters.
Write your train/validation loop bellow. Then train the model until it converges. Feel free to add extra cells.
Draw two diagrams for train and validat ion, one showing loss of each epoch, and another showing accuracy of each epoch.
Evaluate the best epoch's model (according to the validation accuracy) on the test set, and report the accuracy. Is your model overfitted?
Draw 20 misclassified images from test set with expected and predicted labels.
Plot the confusion matrix for the test set.