Vectorized Envrionments¶
Submodules¶
genrl.environments.vec_env.monitor module¶
-
class
genrl.environments.vec_env.monitor.
VecMonitor
(venv: genrl.environments.vec_env.vector_envs.VecEnv, history_length: int = 0, info_keys: Tuple = ())[source]¶ Bases:
genrl.environments.vec_env.wrappers.VecEnvWrapper
Monitor class for VecEnvs. Saves important variables into the info dictionary
Parameters: - venv (object) – Vectorized Environment
- history_length (int) – Length of history for episode rewards and episode lengths
- info_keys (tuple or list) – Important variables to save
genrl.environments.vec_env.normalize module¶
-
class
genrl.environments.vec_env.normalize.
VecNormalize
(venv: genrl.environments.vec_env.vector_envs.VecEnv, norm_obs: bool = True, norm_reward: bool = True, clip_reward: float = 20.0)[source]¶ Bases:
genrl.environments.vec_env.wrappers.VecEnvWrapper
Wrapper to implement Normalization of observations and rewards for VecEnvs
Parameters: - venv (Vectorized Environment) – The Vectorized environment
- n_envs (int) – Number of environments in VecEnv
- norm_obs (bool) – True if observations should be normalized, else False
- norm_reward (bool) – True if rewards should be normalized, else False
- clip_reward (float) – Maximum absolute value for rewards
genrl.environments.vec_env.utils module¶
-
class
genrl.environments.vec_env.utils.
RunningMeanStd
(epsilon: float = 0.0001, shape: Tuple = ())[source]¶ Bases:
object
Utility Function to compute a running mean and variance calculator
Parameters: - epsilon (float) – Small number to prevent division by zero for calculations
- shape (Tuple) – Shape of the RMS object
genrl.environments.vec_env.vector_envs module¶
-
class
genrl.environments.vec_env.vector_envs.
SerialVecEnv
(*args, **kwargs)[source]¶ Bases:
genrl.environments.vec_env.vector_envs.VecEnv
Constructs a wrapper for serial execution through envs.
-
class
genrl.environments.vec_env.vector_envs.
SubProcessVecEnv
(*args, **kwargs)[source]¶ Bases:
genrl.environments.vec_env.vector_envs.VecEnv
Constructs a wrapper for parallel execution through envs.
-
class
genrl.environments.vec_env.vector_envs.
VecEnv
(envs: List[T], n_envs: int = 2)[source]¶ Bases:
abc.ABC
Base class for multiple environments.
Parameters: - env (Gym Environment) – Gym environment to be vectorised
- n_envs (int) – Number of environments
-
action_shape
¶
-
action_spaces
¶
-
n_envs
¶
-
obs_shape
¶
-
observation_spaces
¶
-
genrl.environments.vec_env.vector_envs.
worker
(parent_conn: multiprocessing.context.BaseContext.Pipe, child_conn: multiprocessing.context.BaseContext.Pipe, env: gym.core.Env)[source]¶ Worker class to facilitate multiprocessing
Parameters: - parent_conn (Multiprocessing Pipe Connection) – Parent connection of Pipe
- child_conn (Multiprocessing Pipe Connection) – Child connection of Pipe
- env (Gym Environment) – Gym environment we need multiprocessing for