[tune] save error msg, cleanup after object checkpoints

This commit is contained in:
Eric Liang
2018-01-29 18:48:45 -08:00
committed by GitHub
parent 0b022c0973
commit 35b1d6189b
9 changed files with 49 additions and 29 deletions
+2 -2
View File
@@ -114,9 +114,9 @@ class A3CAgent(Agent):
return result
def _save(self):
def _save(self, checkpoint_dir):
checkpoint_path = os.path.join(
self.logdir, "checkpoint-{}".format(self.iteration))
checkpoint_dir, "checkpoint-{}".format(self.iteration))
agent_state = ray.get(
[a.save.remote() for a in self.remote_evaluators])
extra_data = {
+2 -2
View File
@@ -147,8 +147,8 @@ class _MockAgent(Agent):
episode_reward_mean=10, episode_len_mean=10,
timesteps_this_iter=10, info={})
def _save(self):
path = os.path.join(self.logdir, "mock_agent.pkl")
def _save(self, checkpoint_dir):
path = os.path.join(checkpoint_dir, "mock_agent.pkl")
with open(path, 'wb') as f:
pickle.dump(self.info, f)
return path
+2 -2
View File
@@ -218,10 +218,10 @@ class DQNAgent(Agent):
else:
self.local_evaluator.sample(no_replay=True)
def _save(self):
def _save(self, checkpoint_dir):
checkpoint_path = self.saver.save(
self.local_evaluator.sess,
os.path.join(self.logdir, "checkpoint"),
os.path.join(checkpoint_dir, "checkpoint"),
global_step=self.iteration)
extra_data = [
self.local_evaluator.save(),
+2 -2
View File
@@ -300,9 +300,9 @@ class ESAgent(Agent):
return result
def _save(self):
def _save(self, checkpoint_dir):
checkpoint_path = os.path.join(
self.logdir, "checkpoint-{}".format(self.iteration))
checkpoint_dir, "checkpoint-{}".format(self.iteration))
weights = self.policy.get_weights()
objects = [
weights,
+2 -2
View File
@@ -244,10 +244,10 @@ class PPOAgent(Agent):
return result
def _save(self):
def _save(self, checkpoint_dir):
checkpoint_path = self.saver.save(
self.local_evaluator.sess,
os.path.join(self.logdir, "checkpoint"),
os.path.join(checkpoint_dir, "checkpoint"),
global_step=self.iteration)
agent_state = ray.get(
[a.save.remote() for a in self.remote_evaluators])