1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Images with PyTorch

Connected

Exercise

Classifier block

Your next task is to create a classifier block that will replace the original VGG16 classifier. You decide to use a block with two fully connected layers with a ReLU activation in between.

The vgg_model and input_dim you defined in the last exercise are available in your workspace, and torch and torchvision.models have been imported.

Instructions

100 XP
  • Create a variable num_classes with the number of classes assuming you're dealing with detecting cats and dogs only.
  • Create a sequential block using nn.Sequential.
  • Create a linear layer with in_features set to input_dim.
  • Add the output features to the classifier's last layer.