Policy Utilities

Policy rollout utilities for MyoSuite environments.

myosuite.utils.policy_utils.examine_policy(env, policy, horizon=1000, num_episodes=1, mode='exploration', render=None, camera_name=None, frame_size=(640, 480), output_dir='/tmp/', filename='newvid', device_id=0)

Roll out a policy and return a Trace.

Records are time-aligned, as in myosuite.logger.examine_logs: record t holds the observation, env_infos, reward and done of state s_t and the action taken in it; the last record is the final state with a NaN action. Each state’s info is logged once, so e.g. evaluate_success counts every solved state once.

Parameters:
  • env (Any) – A MyoGymnasiumEnv instance.

  • policy (Any) – Policy object exposing get_action(obs).

  • horizon (int) – Maximum steps per episode.

  • num_episodes (int) – Number of episodes to collect.

  • mode (str) – "exploration" uses stochastic actions; "evaluation" uses deterministic (mean) actions.

  • render (Optional[str]) – "onscreen" / "offscreen" / None.

  • camera_name (Optional[str]) – Camera name (or id) for offscreen rendering; None uses the free camera.

  • frame_size (tuple[int, int]) – (width, height) for offscreen frames.

  • output_dir (str) – Directory for saving MP4 files.

  • filename (str) – Base filename for saved videos.

  • device_id (int) – Unused; kept for signature compatibility.

Return type:

Any

Returns:

A Trace containing all rollout data grouped by episode (Trial0, Trial1, …).