Skip to content

Instantly share code, notes, and snippets.

@pythonlessons
Created January 14, 2020 12:40
Show Gist options
  • Save pythonlessons/bd623a485b275c637c4c529db4379a09 to your computer and use it in GitHub Desktop.
Save pythonlessons/bd623a485b275c637c4c529db4379a09 to your computer and use it in GitHub Desktop.
02_CartPole-reinforcement-learning_DDQN
pylab.figure(figsize=(18, 9))
def PlotModel(self, score, episode):
self.scores.append(score)
self.episodes.append(episode)
self.average.append(sum(self.scores) / len(self.scores))
pylab.plot(self.episodes, self.average, 'r')
pylab.plot(self.episodes, self.scores, 'b')
pylab.ylabel('Score', fontsize=18)
pylab.xlabel('Steps', fontsize=18)
dqn = 'DQN_'
softupdate = ''
if self.ddqn:
dqn = 'DDQN_'
if self.Soft_Update:
softupdate = '_soft'
try:
pylab.savefig(dqn+self.env_name+softupdate+".png")
except OSError:
pass
return str(self.average[-1])[:5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment