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

Exports policy model with given policy_id to a local directory.

  • 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
>>> # Use an Algorithm from RLlib or define your own.
>>> algo = PPO(...) 
>>> for _ in range(10): 
>>>     algo.train() 
>>> algo.export_policy_model("/tmp/dir") 
>>> algo.export_policy_model("/tmp/dir/onnx", onnx=1)