Environments Utils
- stable_baselines3.common.env_util.is_wrapped(env, wrapper_class)[source]
Check if a given environment has been wrapped with a given wrapper.
- Parameters:
env (Env) – Environment to check
wrapper_class (Type[Wrapper]) – Wrapper class to look for
- Returns:
True if environment has been wrapped with
wrapper_class.- Return type:
bool
- stable_baselines3.common.env_util.make_atari_env(env_id, n_envs=1, seed=None, start_index=0, monitor_dir=None, wrapper_kwargs=None, env_kwargs=None, vec_env_cls=None, vec_env_kwargs=None, monitor_kwargs=None)[source]
Create a wrapped, monitored VecEnv for Atari. It is a wrapper around
make_vec_envthat includes common preprocessing for Atari games.- Parameters:
env_id (str | Callable[[...], Env]) – either the env ID, the env class or a callable returning an env
n_envs (int) – the number of environments you wish to have in parallel
seed (int | None) – the initial seed for the random number generator
start_index (int) – start rank index
monitor_dir (str | None) – Path to a folder where the monitor files will be saved. If None, no file will be written, however, the env will still be wrapped in a Monitor wrapper to provide additional information about training.
wrapper_kwargs (Dict[str, Any] | None) – Optional keyword argument to pass to the
AtariWrapperenv_kwargs (Dict[str, Any] | None) – Optional keyword argument to pass to the env constructor
vec_env_cls (Type[DummyVecEnv] | Type[SubprocVecEnv] | None) – A custom
VecEnvclass constructor. Default: None.vec_env_kwargs (Dict[str, Any] | None) – Keyword arguments to pass to the
VecEnvclass constructor.monitor_kwargs (Dict[str, Any] | None) – Keyword arguments to pass to the
Monitorclass constructor.
- Returns:
The wrapped environment
- Return type:
- stable_baselines3.common.env_util.make_vec_env(env_id, n_envs=1, seed=None, start_index=0, monitor_dir=None, wrapper_class=None, env_kwargs=None, vec_env_cls=None, vec_env_kwargs=None, monitor_kwargs=None, wrapper_kwargs=None)[source]
Create a wrapped, monitored
VecEnv. By default it uses aDummyVecEnvwhich is usually faster than aSubprocVecEnv.- Parameters:
env_id (str | Callable[[...], Env]) – either the env ID, the env class or a callable returning an env
n_envs (int) – the number of environments you wish to have in parallel
seed (int | None) – the initial seed for the random number generator
start_index (int) – start rank index
monitor_dir (str | None) – Path to a folder where the monitor files will be saved. If None, no file will be written, however, the env will still be wrapped in a Monitor wrapper to provide additional information about training.
wrapper_class (Callable[[Env], Env] | None) – Additional wrapper to use on the environment. This can also be a function with single argument that wraps the environment in many things. Note: the wrapper specified by this parameter will be applied after the
Monitorwrapper. if some cases (e.g. with TimeLimit wrapper) this can lead to undesired behavior. See here for more details: https://github.com/DLR-RM/stable-baselines3/issues/894env_kwargs (Dict[str, Any] | None) – Optional keyword argument to pass to the env constructor
vec_env_cls (Type[DummyVecEnv | SubprocVecEnv] | None) – A custom
VecEnvclass constructor. Default: None.vec_env_kwargs (Dict[str, Any] | None) – Keyword arguments to pass to the
VecEnvclass constructor.monitor_kwargs (Dict[str, Any] | None) – Keyword arguments to pass to the
Monitorclass constructor.wrapper_kwargs (Dict[str, Any] | None) – Keyword arguments to pass to the
Wrapperclass constructor.
- Returns:
The wrapped environment
- Return type:
- stable_baselines3.common.env_util.unwrap_wrapper(env, wrapper_class)[source]
Retrieve a
VecEnvWrapperobject by recursively searching.- Parameters:
env (Env) – Environment to unwrap
wrapper_class (Type[Wrapper]) – Wrapper to look for
- Returns:
Environment unwrapped till
wrapper_classif it has been wrapped with it- Return type:
Wrapper | None