COLAB LINK
I trained a model (Lenet-5) for 10 epochs and saved the model as follows
state = {
‘model’: model.state_dict(),
‘optimizer’: optimizer.state_dict(),
‘scheduler’: scheduler.state_dict()
}
th.save(state,’/Documents/saved_model.pt’)
loaded into 2 models ‘new_model’, ‘new_model2’ as below
new_model= model2().cuda()
new_model2= model2().cuda()
checkpoint = th.load(’/home/hareesh/Documents/sar/information_theory/lenet/saved_model.pt’)
checkpoint2 = th.load(’/home/hareesh/Documents/sar/information_theory/lenet/saved_model.pt’)
new_optimizer=th.optim.SGD(new_model.parameters(), lr=0.1,momentum=0.9,weight_decay=5e-4)
new_scheduler = MultiStepLR(new_optimizer,milestones=[10,20], gamma=0.1)
new_optimizer2= th.optim.SGD(new_model2.parameters(), lr=0.1,momentum=0.9,weight_decay=5e-4)
new_scheduler2 = MultiStepLR(new_optimizer2,milestones=[10,20], gamma=0.1)
new_model.load_state_dict(checkpoint[‘model’])
new_model2.load_state_dict(checkpoint[‘model’])
new_optimizer.load_state_dict(checkpoint[‘optimizer’])
new_optimizer2.load_state_dict(checkpoint[‘optimizer’])
new_scheduler.load_state_dict(checkpoint[‘scheduler’])
new_scheduler2.load_state_dict(checkpoint[‘scheduler’])
trained the new models for 5 epochs,but the results are different.
Also when i continue training the original model for 5 more epochs ,the results are also different from the training results of 2 new models.
Is it possible that the test and train accuracies of original model(15 epochs), 2 new models(5 epochs after loading from the checkpoint) will be same?
(From loaded checkpoint im getting same test accuracy for all 3 models, if not training any of the models)