有谁知道如何在ray-rllib中为算法训练器模型做检查点和保存模型?
我知道这对于ray.tune是可用的,但是对于rllib算法,似乎不可能直接这样做。
发布于 2022-05-25 15:01:43
训练器类有save_checkpoint方法和load_checkpoint方法。
@override(Trainable)
def save_checkpoint(self, checkpoint_dir: str) -> str:
checkpoint_path = os.path.join(
checkpoint_dir, "checkpoint-{}".format(self.iteration)
)
pickle.dump(self.__getstate__(), open(checkpoint_path, "wb"))
return checkpoint_path
@override(Trainable)
def load_checkpoint(self, checkpoint_path: str) -> None:
extra_data = pickle.load(open(checkpoint_path, "rb"))
self.__setstate__(extra_data)https://stackoverflow.com/questions/67881373
复制相似问题