ray.rllib.policy.eager_tf_policy_v2.EagerTFPolicyV2.from_checkpoint#

static EagerTFPolicyV2.from_checkpoint(checkpoint: str | Checkpoint, policy_ids: Container[str] | None = None) Policy | Dict[str, Policy]#

Creates new Policy instance(s) from a given Policy or Algorithm checkpoint.

Note: This method must remain backward compatible from 2.1.0 on, wrt. checkpoints created with Ray 2.0.0 or later.

Parameters:
  • checkpoint – The path (str) to a Policy or Algorithm checkpoint directory or an AIR Checkpoint (Policy or Algorithm) instance to restore from. If checkpoint is a Policy checkpoint, policy_ids must be None and only the Policy in that checkpoint is restored and returned. If checkpoint is an Algorithm checkpoint and policy_ids is None, will return a list of all Policy objects found in the checkpoint, otherwise a list of those policies in policy_ids.

  • policy_ids – List of policy IDs to extract from a given Algorithm checkpoint. If None and an Algorithm checkpoint is provided, will restore all policies found in that checkpoint. If a Policy checkpoint is given, this arg must be None.

Returns:

An instantiated Policy, if checkpoint is a Policy checkpoint. A dict mapping PolicyID to Policies, if checkpoint is an Algorithm checkpoint. In the latter case, returns all policies within the Algorithm if policy_ids is None, else a dict of only those Policies that are in policy_ids.