ray.rllib.algorithms.algorithm.Algorithm.export_policy_model#

Algorithm.export_policy_model(export_dir: str, policy_id: str = 'default_policy', onnx: int | None = None) None[source]#

Exports policy model with given policy_id to a local directory.

Parameters:
  • export_dir – Writable local directory.

  • policy_id – Optional policy id to export.

  • onnx – If given, will export model in ONNX format. The value of this parameter set the ONNX OpSet version to use. If None, the output format will be DL framework specific.

from ray.rllib.algorithms.ppo import PPO, PPOConfig
config = PPOConfig().environment("CartPole-v1")
algo = PPO(config=config)
algo.train()
algo.export_policy_checkpoint("/tmp/export_dir")
algo.export_policy_model("/tmp/dir")