i_am_somebody
i_am_somebody

Reputation: 23

How to remove the adaptive average pool layer from vgg19?

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

Upvotes: 2

Views: 700

Answers (1)

Solaiman Salvi
Solaiman Salvi

Reputation: 645

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.

Upvotes: 3

Related Questions