I saved and loaded a model using
torch.save({'state_dict': model.state_dict()}, "classifier.pth")
state_dict = torch.load('classifier.pth')
model.load_state_dict(state_dict["state_dict"])
I was getting 93% accuracy in a classification on the validation set which got reduced to 76% after I restarted the kernel… Am I making some mistake…Please help
anilg
(Anıl)
April 23, 2020, 10:10am
2
That shouldn’t be. Are you sure that you are feeding the same dataset?
Yes I didnt change anything , just restarted the kernel…
I am adding some screenshots of new results…
Here I loaded the model
Here I restarted the kernel and loaded the model
I see it’s an old discussion but I’d recommend setting seed value
I saved it this way, so was working fine
torch.save(model, ‘filename.pt’)
1 Like