runners

runners#

Functions#

prt_rl.common.runners.watch(env: EnvironmentInterface, policy: Policy, num_episodes: int = 1) None[source]#

Watch a trained RL agent in a gym environment.

Parameters:
  • env – The environment to run the agent in.

  • policy – The RL policy to use for acting in the environment.

Classes#

class prt_rl.common.runners.Runner(env: EnvironmentInterface, agent: Agent, recorders: List[Recorder] | None = None, visualizer: Visualizer | None = None)[source]#

A runner executes an agent in an environment. It simplifies the process of evaluating agents that have been trained.

The runner assumes the rgb_array is in the info dictioanary and has shape (num_envs, channel, height, width).

Note

To use the visualizer, the environment wrapper render mode must be set to ‘rgb_array’.

Parameters:
  • env (EnvironmentInterface) – the environment to run the agent in

  • agent (BaseAgent) – Agent to be executed in the environment

  • recorders (Optional[List[Recorder]]) – List of recorders to record the experience and info during the run

  • visualizer (Optional[Visualizer]) – Visualizer to show the environment frames during the run