ray.rllib.algorithms.algorithm.Algorithm.export_policy_model
ray.rllib.algorithms.algorithm.Algorithm.export_policy_model#
- 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.
- 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.
Example
>>> 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)