I have trained Resnet50 provided by torchvision.models on my own dataset. And because my dataset has 100 classes, I modified the fc layer, and everything goes fine. After finishing the training, I use torch.save(best_model, path) to save the best model.
Now I want to load the best model to predict on the test set, So I load the model structure as model = torch.load(path), and print the model as follows:

image.png799×474 16.4 KB

We can see that the out_features of fc layer is 100, but the size of output became 1000, is it weird? How to solve this problem?