February 2018
Intermediate to advanced
262 pages
6h 59m
English
We will load a pretrained model from torchvisions.models. We will be using this model only for extracting features, and the PyTorch VGG model is defined in such a way that all the convolutional blocks will be in the features module and the fully connected, or linear, layers are in the classifier module. Since we will not be training any of the weights or parameters in the VGG model, we will also freeze the model. The following code demonstrates the same:
#Creating a pretrained VGG modelvgg = vgg19(pretrained=True).features#Freezing the layers as we will not use it for training.for param in vgg.parameters(): param.requires_grad = False
In this code, we created a VGG model, used only its convolution blocks and froze all ...