BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Deep Learning for Images with PyTorch

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

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

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Load pretrained weights
vgg_model = vgg16(weights=____)

# Extract the input dimension
input_dim = nn.Sequential(*list(vgg_model.classifier.____()))[0].____

# Create a backbone with convolutional layers
backbone = nn.Sequential(*list(____))

# Print the backbone model
____
Kodu Düzenle ve Çalıştır