Hi,
Yes, because squeezenet does not use Linear in its definition so there is no need to define the structure like ResNet or Inception. But you can get the structure of model using print(model)
and extract layers that you want.
Based on your example code, I think you looking for dropping final classifier and train your own linear classifier for it.
Original classfier of squeezenet:
(classifier): Sequential(
(0): Dropout(p=0.5, inplace=False)
(1): Conv2d(512, 1000, kernel_size=(1, 1), stride=(1, 1))
(2): ReLU(inplace=True)
(3): AdaptiveAvgPool2d(output_size=(1, 1))
)
To change it the way you want, this snippet may help, although you can modify it in anyway you like:
x = torch.randn(1, 3, 512, 512)
model = torchvision.models.squeezenet.squeezenet1_0(pretrained=True)
model.classifier = nn.Sequential(
nn.AdaptiveAvgPool2d(output_size=(1, 1)),
nn.Dropout(0.5),
nn.Flatten(),
nn.Linear(in_features=512, out_features=5),
)
model(x)
Bests