docstrings about vecenvs
This commit is contained in:
@@ -25,7 +25,10 @@ class NotSteppingError(Exception):
|
||||
|
||||
class VecEnv(ABC):
|
||||
"""
|
||||
An abstract asynchronous, vectorized environment.
|
||||
An abstract asynchronous, vectorized environment.
|
||||
Used to batch data from multiple copies of an environment, so that
|
||||
each observation becomes an batch of observations, and expected action is a batch of actions to
|
||||
be applied per-environment.
|
||||
"""
|
||||
|
||||
def __init__(self, num_envs, observation_space, action_space):
|
||||
|
@@ -4,7 +4,18 @@ from . import VecEnv
|
||||
from .util import copy_obs_dict, dict_to_obs, obs_space_info
|
||||
|
||||
class DummyVecEnv(VecEnv):
|
||||
"""
|
||||
VecEnv that does runs multiple environments sequentially, that is,
|
||||
the step and reset commands are send to one environment at a time.
|
||||
Useful when debugging and when num_env == 1 (in the latter case,
|
||||
avoids communication overhead)
|
||||
"""
|
||||
def __init__(self, env_fns):
|
||||
"""
|
||||
Arguments:
|
||||
|
||||
env_fns: iterable of callables functions that build environments
|
||||
"""
|
||||
self.envs = [fn() for fn in env_fns]
|
||||
env = self.envs[0]
|
||||
VecEnv.__init__(self, len(env_fns), env.observation_space, env.action_space)
|
||||
|
@@ -19,8 +19,7 @@ _NP_TO_CT = {np.float32: ctypes.c_float,
|
||||
|
||||
class ShmemVecEnv(VecEnv):
|
||||
"""
|
||||
An AsyncEnv that uses multiprocessing to run multiple
|
||||
environments in parallel.
|
||||
Optimized version of SubprocVecEnv that uses shared variables to communicate observations.
|
||||
"""
|
||||
|
||||
def __init__(self, env_fns, spaces=None):
|
||||
|
@@ -32,9 +32,15 @@ def worker(remote, parent_remote, env_fn_wrapper):
|
||||
|
||||
|
||||
class SubprocVecEnv(VecEnv):
|
||||
"""
|
||||
VecEnv that runs multiple environments in parallel in subproceses and communicates with them via pipes.
|
||||
Recommended to use when num_envs > 1 and step() can be a bottleneck.
|
||||
"""
|
||||
def __init__(self, env_fns, spaces=None):
|
||||
"""
|
||||
envs: list of gym environments to run in subprocesses
|
||||
Arguments:
|
||||
|
||||
env_fns: iterable of callables - functions that create environments to run in subprocesses. Need to be cloud-pickleable
|
||||
"""
|
||||
self.waiting = False
|
||||
nenvs = len(env_fns)
|
||||
|
Reference in New Issue
Block a user