mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 16:40:00 +08:00
[tune] Recover experiments from last checkpoint (#1532)
This commit is contained in:
@@ -139,12 +139,19 @@ class _MockAgent(Agent):
|
||||
"""Mock agent for use in tests"""
|
||||
|
||||
_agent_name = "MockAgent"
|
||||
_default_config = {}
|
||||
_default_config = {
|
||||
"mock_error": False,
|
||||
"persistent_error": False,
|
||||
}
|
||||
|
||||
def _init(self):
|
||||
self.info = None
|
||||
self.restored = False
|
||||
|
||||
def _train(self):
|
||||
if self.config["mock_error"] and self.iteration == 1 \
|
||||
and (self.config["persistent_error"] or not self.restored):
|
||||
raise Exception("mock error")
|
||||
return TrainingResult(
|
||||
episode_reward_mean=10, episode_len_mean=10,
|
||||
timesteps_this_iter=10, info={})
|
||||
@@ -159,6 +166,7 @@ class _MockAgent(Agent):
|
||||
with open(checkpoint_path, 'rb') as f:
|
||||
info = pickle.load(f)
|
||||
self.info = info
|
||||
self.restored = True
|
||||
|
||||
def set_info(self, info):
|
||||
self.info = info
|
||||
|
||||
@@ -174,7 +174,9 @@ class DQNEvaluator(TFMultiGPUSupport):
|
||||
self.episode_rewards,
|
||||
self.episode_lengths,
|
||||
self.saved_mean_reward,
|
||||
self.obs]
|
||||
self.obs,
|
||||
self.global_timestep,
|
||||
self.local_timestep]
|
||||
|
||||
def restore(self, data):
|
||||
self.exploration = data[0]
|
||||
@@ -182,3 +184,5 @@ class DQNEvaluator(TFMultiGPUSupport):
|
||||
self.episode_lengths = data[2]
|
||||
self.saved_mean_reward = data[3]
|
||||
self.obs = data[4]
|
||||
self.global_timestep = data[5]
|
||||
self.local_timestep = data[6]
|
||||
|
||||
Reference in New Issue
Block a user