Sorry about the formatting,So the basic code is :
model_state = torch.load(“latest_model.pth”)
model.load_state_dict(state[‘state_dict’])
optimizer_state = torch.load(“latest_optim.pth”)
optimizer = torch.load(optimzer_state[“state_dict”])
for epoch in xrange(no_of_epochs):
model.train()
#basic training code
model.eval()
#basic validation code
The only diffenrece is that I have made functions for training and testing where the model and optimizer are the parameters for it. I dont think accounts for “copying the model”.