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

Connected

Exercise

Pre-trained model backbone

It's time to build an R-CNN architecture! You will use the vgg16 pre-trained model's backbone for feature extraction. You also remember to store the output shape of the backbone which will serve as the input shape for the subsequent blocks: the classifier and the box regressor.

torch, torchvision, torch.nn as nn have been imported. The model has been imported as vgg16 with the weights stored in VGG16_Weights.

Instructions

100 XP
  • Load the pre-trained VGG16 weights.
  • Extract in_features from the classifier's first layer using .children() as a sequential block and store it as input_dim.
  • Create a backbone as a sequential block using features and .children().
  • Print the backbone model.