2

I have loaded the pre-trained model of vgg19. How to remove the adaptive average pool layer which is present before the classifier?

1 Answers1

3

If you are using PyTorch and torchVision model, you can disable the use of the last maxpool layer like this -

nn.Sequential(*list(vgg.features._modules.values())[:-1])

Here all the layers are in an array, and not including the last element does the trick.

Solaiman Salvi
  • 577
  • 4
  • 9