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

In [ ]:
 

Get Inception V3

Instantiate Inception V3 model (pretrained on imagenet) from torchvision's model zoo.

In [ ]:
 

Modify for CIFAR10

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 [ ]:
 

Freeze the convolutional part

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.

In [ ]:
 

Instantiate the optimizer

Create the optimizer filtering out freezed parameters.

In [ ]:
 

Train the model

Write your train/validation loop bellow. Then train the model until it converges. Feel free to add extra cells.

In [ ]:
 

Draw the training curves

Draw two diagrams for train and validat ion, one showing loss of each epoch, and another showing accuracy of each epoch.

In [ ]:
 

Evaluate your model

Evaluate the best epoch's model (according to the validation accuracy) on the test set, and report the accuracy. Is your model overfitted?

In [ ]:
 

Draw misclassified images

Draw 20 misclassified images from test set with expected and predicted labels.

In [ ]:
 

Plot the confusion matrix

Plot the confusion matrix for the test set.

In [ ]: