Thanks for your reply. My code is as follows:

m2 = torchvision.models.resnet50(pretrained=True)
m2.fc.out_features = 100

# after training
...
torch.save(m2, 'best.pt')


Then I use ipython to load the model:
[1] import torch

[2] m2 = torch.load('best.pt')

[3] m2
the model architecture is shown as above figure.

[4] m2(torch.rand(1,3,224,224).cuda(0)).shape

but the result of [4] is torch.Size([1, 1000])