Hello guys, Im trying to make finnetuning with a googlenet pretrained model. I only want to modify the fully connected layers. For that reason, I tried to extract the feature part without the fully connected layers, the avgpool and flatten functions from the pretrained model, but I got an error.
AttributeError: 'GoogLeNet' object has no attribute 'features'
Do you know how to extract the convolutional part from the google net architecture or similar architectures without the feature object?
I saw one form used in Resnet 18 from covid19_pocus_ultrasound_pytorch/code/models/resnet.py at main · ar-ambuj23/covid19_pocus_ultrasound_pytorch · GitHub
And he used:
self.model = nn.Sequential(*list(self.model.children())[:-1])
The code that I used is
self.model = models.googlenet(pretrained=True)
# freeze weights of base model except last cnn layer
# model.parameters() does not include max pooling layers
for param in self.model.parameters():
param.requires_grad = False
# Taking only sequential part
self.model = self.model.features
And is addapted from covid19_pocus_ultrasound_pytorch/code/models/vgg.py at main · ar-ambuj23/covid19_pocus_ultrasound_pytorch · GitHub