imitation.scripts.ingredients.environment#

This ingredient provides a vectorized gym environment.

Functions

make_rollout_venv(gym_id, num_vec, parallel, ...)

Builds the vector environment for rollouts.

make_venv(gym_id, num_vec, parallel, ...)

Builds the vector environment.

imitation.scripts.ingredients.environment.make_rollout_venv(gym_id, num_vec, parallel, max_episode_steps, env_make_kwargs, _rnd)[source]#

Builds the vector environment for rollouts.

This environment does no logging, and it is wrapped in a RolloutInfoWrapper.

Parameters
  • gym_id (str) – The id of the environment to create.

  • num_vec (int) – Number of gym.Env instances to combine into a vector environment.

  • parallel (bool) – Whether to use “true” parallelism. If True, then use SubProcVecEnv. Otherwise, use DummyVecEnv which steps through environments serially.

  • max_episode_steps (int) – If not None, then a TimeLimit wrapper is applied to each environment to artificially limit the maximum number of timesteps in an episode.

  • env_make_kwargs (Mapping[str, Any]) – The kwargs passed to spec.make of a gym environment.

  • _rnd (Generator) – Random number generator provided by Sacred.

Yields

The constructed vector environment.

Return type

Generator[VecEnv, None, None]

imitation.scripts.ingredients.environment.make_venv(gym_id, num_vec, parallel, max_episode_steps, env_make_kwargs, _run, _rnd, **kwargs)[source]#

Builds the vector environment.

Parameters
  • gym_id (str) – The id of the environment to create.

  • num_vec (int) – Number of gym.Env instances to combine into a vector environment.

  • parallel (bool) – Whether to use “true” parallelism. If True, then use SubProcVecEnv. Otherwise, use DummyVecEnv which steps through environments serially.

  • max_episode_steps (int) – If not None, then a TimeLimit wrapper is applied to each environment to artificially limit the maximum number of timesteps in an episode.

  • env_make_kwargs (Mapping[str, Any]) – The kwargs passed to spec.make of a gym environment.

  • kwargs – Passed through to util.make_vec_env.

Yields

The constructed vector environment.

Return type

Generator[VecEnv, None, None]