Shortcuts

framework.middleware.ckpt_handler

ckpt_handler

CkptSaver

class ding.framework.middleware.ckpt_handler.CkptSaver(*args, **kwargs)[source]
Overview:

The class used to save checkpoint data.

__call__(ctx: OnlineRLContext | OfflineRLContext) None[source]
Overview:

The method used to save checkpoint data. The checkpoint data will be saved in a file in following 3 cases: - When a multiple of self.train_freq iterations have elapsed since the beginning of training; - When the evaluation episode return is the best so far; - When task.finish is True.

Input of ctx:
  • train_iter (int): Number of training iteration, i.e. the number of updating policy related network.

  • eval_value (float): The episode return of current iteration.

__init__(policy: Policy, save_dir: str, train_freq: int | None = None, save_finish: bool = True)[source]
Overview:

Initialize the CkptSaver.

Arguments:
  • policy (Policy): Policy used to save the checkpoint.

  • save_dir (str): The directory path to save ckpt.

  • train_freq (int): Number of training iterations between each saving checkpoint data.

  • save_finish (bool): Whether save final ckpt when task.finish = True.