Edit: Looking closer, I see that your model is correct. Are you sure that the model you are printing is the model m2 used for the input?
Hi there. Hmm, can you show us how you changed the model? Or print the model after you’ve changed it?
When I do resnet.fc = nn.Linear(self.basenet.fc.in_features, n_out_features) it works fine after saving/loading
My code ->
n_features = 100
resnet = models.resnet18()
resnet.fc = nn.Linear(resnet.fc.in_features, n_features)
torch.save(resnet, 'model.pth')
model = torch.load('model.pth')

inp = torch.randn(1, 3, 224, 224)
out = model(inp)
print(out.size()) -> torch.Size([1, 100])