mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 12:18:02 +08:00
[tune] save error msg, cleanup after object checkpoints
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user