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 checkwrapper_class (
Type[Wrapper]) – Wrapper class to look for
- Return type:
bool- Returns:
True if environment has been wrapped with
wrapper_class.
- 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 (
Union[str,Callable[...,Env]]) – either the env ID, the env class or a callable returning an envn_envs (
int) – the number of environments you wish to have in parallelseed (
Optional[int]) – the initial seed for the random number generatorstart_index (
int) – start rank indexmonitor_dir (
Optional[str]) – 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 (
Optional[Dict[str,Any]]) – Optional keyword argument to pass to theAtariWrapperenv_kwargs (
Optional[Dict[str,Any]]) – Optional keyword argument to pass to the env constructorvec_env_cls (
Union[Type[DummyVecEnv],Type[SubprocVecEnv],None]) – A customVecEnvclass constructor. Default: None.vec_env_kwargs (
Optional[Dict[str,Any]]) – Keyword arguments to pass to theVecEnvclass constructor.monitor_kwargs (
Optional[Dict[str,Any]]) – Keyword arguments to pass to theMonitorclass constructor.
- Return type:
- Returns:
The wrapped environment
- 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 (
Union[str,Callable[...,Env]]) – either the env ID, the env class or a callable returning an envn_envs (
int) – the number of environments you wish to have in parallelseed (
Optional[int]) – the initial seed for the random number generatorstart_index (
int) – start rank indexmonitor_dir (
Optional[str]) – 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 (
Optional[Callable[[Env],Env]]) – 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 theMonitorwrapper. 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 (
Optional[Dict[str,Any]]) – Optional keyword argument to pass to the env constructorvec_env_cls (
Optional[Type[Union[DummyVecEnv,SubprocVecEnv]]]) – A customVecEnvclass constructor. Default: None.vec_env_kwargs (
Optional[Dict[str,Any]]) – Keyword arguments to pass to theVecEnvclass constructor.monitor_kwargs (
Optional[Dict[str,Any]]) – Keyword arguments to pass to theMonitorclass constructor.wrapper_kwargs (
Optional[Dict[str,Any]]) – Keyword arguments to pass to theWrapperclass constructor.
- Return type:
- Returns:
The wrapped environment
- stable_baselines3.common.env_util.unwrap_wrapper(env, wrapper_class)[source]¶
Retrieve a
VecEnvWrapperobject by recursively searching.- Parameters:
env (
Env) – Environment to unwrapwrapper_class (
Type[Wrapper]) – Wrapper to look for
- Return type:
Optional[Wrapper]- Returns:
Environment unwrapped till
wrapper_classif it has been wrapped with it