Accuracy decrease after load the saved resnet50 model

Hi
This Problem reported in

However, does not solve.
I have the same problem,

validation and train accuracy of ResNet50 decreased 70% when I loaded the model with load_state_dict() function !!!
However, when I save the training results everything was OK
I use torchvision.models.resnet50 train it with CFAR100 and get 96%, 76% train and test accuracy, save the model satte and then load it with the same hyperparameter.
However I get 40%, 3% train, and test accuracy,
any help is appreciated.

Could you compare the outputs of the model for a static input (e.g torch.ones) and after calling model.eva() before saving the state_dict and after loading it?
If the result is equal (up to floating point precision) then I would recommend to check the data loading and make sure both scripts use the same data processing steps.

1 Like

Thank,s ptrblck
I do what you suggest and find my bug, in fact, it is my fault in the forward function,
in the first training I use torch.vision forward function,
but the second time when I load the saved model I implemented a custom forward function,
It is my error in custom forward function implementation ,