Get Features of VGG16 Pretrained Model

Could anyone show me how to get features of any pre-trained models (say VGG16)?

You will first need to load the model, this can be done using:

pretrained_model = torchvision.models.vgg16()
feature_extractor = nn.Sequential(*list(pretrained_model.children())[:-1])

Then you can use the feature extractor model to extract features from the network.