Hi David,
Yes it’s not possible to use the restore method because it resumes the run with no changes to the config. However, you should load the checkpoint you want to restore from and save the weights. For Tensorflow this can be done like this (Ray 2.0.x):
After tuner.fit():
tune_config = {“env”: “XXX-v0”, # put your env here
“model”: {“custom_model”:“LightModel”},
“framework”: “tf2”,
“eager_tracing”: True}
default_config = impala.DEFAULT_CONFIG.copy()
config = default_config | tune_config
trainer = impala.Impala(config=config)
trainer.restore(“path_to_checkpoint_you_want_to_restart_from”)
ckp_num = “1000” # or whatever…
weights = trainer.get_policy().get_weights()
trainer.get_policy().model.base_model_actor.save_weights(“light_model_actor_” + ckp_num + “ckp.h5")
trainer.get_policy().model.base_model_critic.save_weights("light_model_critic” + ckp_num + “_ckp.h5”)
Then subclass the algorithm you want to use and define custom model - might just be the default model:
class Impalaalgo(impala.Impala): # inspired by another issue but can’t remember the number
def init(self, config, **kwargs):
super(Impalaalgo, self).init(config, **kwargs)
“”" Needs full path here!“”"
_cwd = os.path.dirname(os.path.abspath(file))
actor_weights = _cwd +“/light_model_actor_180_ckp.h5”
critic_weights = _cwd +“/light_model_critic_180_ckp.h5”
self.get_policy().model.import_from_h5([actor_weights, critic_weights])
self.workers.sync_weights() # Important!!!
def reset_config(self, new_config):
""" to enable reuse of actors """
self.config = new_config
return True
And then do a new tuner.fit() with another config like this:
tuner = tune.Tuner(
Impalaalgo,
run_config=air.RunConfig(
name=“Impalaalgo_run2”, …
param_space =my_new_config,…
…)
I hope this bring you forward.
BR Jorgen