Problems about resuming training my DQN model in Pytorch

32 Views Asked by At

I'm trying to train a DQN model for UAV 3D obstacle avoidance task. It gets score around 80000 when training at 10,000 epoch. I have saved the model through torch.save(). However, when I load the model and try to resume training, the score was -110,000. I don't know why. I didn't change training dataset. My code are as follows:

# save model
state = {'model': env.q_target.state_dict(), 'optimizer': env.optim.state_dict(), 'epoch': i_episode+epoch}
torch.save(state, "Qtarget.pth")
state = {'model': env.q_local.state_dict(), 'optimizer': env.optim.state_dict(), 'epoch': i_episode+epoch}
torch.save(state, "Qlocal.pth")

# load model, the net and optimizer are initialized in env.__init__.
env = Environment(map_data,space_dim,action_dim,LEARNING_RATE)
check_point_Qlocal=torch.load('Qlocal.pth')
check_point_Qtarget=torch.load('Qtarget.pth')
env.q_target.load_state_dict(check_point_Qtarget['model'])
env.q_local.load_state_dict(check_point_Qlocal['model'])
env.optim.load_state_dict(check_point_Qlocal['optimizer'])
epoch=check_point_Qlocal['epoch']

I want to resume my training with a similar score.

0

There are 0 best solutions below