garage.envs.wrappers package¶
gym.Env wrappers.
Used to transform an environment in a modular way. It is also possible to apply multiple wrappers at the same time.
Example
StackFrames(GrayScale(gym.make(‘env’)))
-
class
AtariEnv
(env)[source]¶ Bases:
gym.core.Wrapper
Atari environment wrapper for gym.Env.
This wrapper convert the observations returned from baselines wrapped environment, which is a LazyFrames object into numpy arrays.
Parameters: env (gym.Env) – The environment to be wrapped.
-
class
EpisodicLife
(env)[source]¶ Bases:
gym.core.Wrapper
Episodic life wrapper for gym.Env.
This wrapper makes episode end when a life is lost, but only reset when all lives are lost.
Parameters: env – The environment to be wrapped.
-
class
FireReset
(env)[source]¶ Bases:
gym.core.Wrapper
Fire reset wrapper for gym.Env.
Take action “fire” on reset.
Parameters: env (gym.Env) – The environment to be wrapped.
-
class
Grayscale
(env)[source]¶ Bases:
gym.core.Wrapper
Grayscale wrapper for gym.Env, converting frames to grayscale.
Only works with gym.spaces.Box environment with 2D RGB frames. The last dimension (RGB) of environment observation space will be removed.
Example
env = gym.make(‘Env’) # env.observation_space = (100, 100, 3)
env_wrapped = Grayscale(gym.make(‘Env’)) # env.observation_space = (100, 100)
Parameters: env – gym.Env to wrap. Raises: ValueError
– If observation space shape is not 3 or environment is not gym.spaces.Box.-
observation_space
¶ gym.Env observation space.
-
-
class
MaxAndSkip
(env, skip=4)[source]¶ Bases:
gym.core.Wrapper
Max and skip wrapper for gym.Env.
It returns only every skip-th frame. Action are repeated and rewards are sum for the skipped frames.
It also takes element-wise maximum over the last two consecutive frames, which helps algorithm deal with the problem of how certain Atari games only render their sprites every other game frame.
Parameters: - env – The environment to be wrapped.
- skip – The environment only returns skip-th frame.
-
class
Noop
(env, noop_max=30)[source]¶ Bases:
gym.core.Wrapper
Noop wrapper for gym.Env.
It samples initial states by taking random number of no-ops on reset. No-op is assumed to be action 0.
Parameters: - env (gym.Env) – The environment to be wrapped.
- noop_max (int) – Maximum number no-op to be performed on reset.
-
class
Resize
(env, width, height)[source]¶ Bases:
gym.core.Wrapper
gym.Env wrapper for resizing frame to (width, height).
Only works with gym.spaces.Box environment with 2D single channel frames.
Example
env = gym.make(‘Env’)# env.observation_space = (100, 100)env_wrapped = Resize(gym.make(‘Env’), width=64, height=64)# env.observation_space = (64, 64)Parameters: - env – gym.Env to wrap.
- width – resized frame width.
- height – resized frame height.
Raises: ValueError
– If observation space shape is not 2 or environment is not gym.spaces.Box.-
observation_space
¶ gym.Env observation space.
-
class
StackFrames
(env, n_frames)[source]¶ Bases:
gym.core.Wrapper
gym.Env wrapper to stack multiple frames.
Useful for training feed-forward agents on dynamic games. Only works with gym.spaces.Box environment with 2D single channel frames.
Parameters: - env – gym.Env to wrap.
- n_frames – number of frames to stack.
Raises: ValueError
– If observation space shape is not 2 or- environment is not gym.spaces.Box.
-
observation_space
¶ gym.Env observation space.
Submodules¶
- garage.envs.wrappers.atari_env module
- garage.envs.wrappers.clip_reward module
- garage.envs.wrappers.episodic_life module
- garage.envs.wrappers.fire_reset module
- garage.envs.wrappers.grayscale module
- garage.envs.wrappers.max_and_skip module
- garage.envs.wrappers.noop module
- garage.envs.wrappers.resize module
- garage.envs.wrappers.stack_frames module