Skip to content

General purpose environment wrappers for openai gym

License

Notifications You must be signed in to change notification settings

ngc92/space-wrappers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

space-wrappers

Travis

General purpose environment wrappers for openai gym.

List of currently implemented Wrappers

For a description of what these wrappers do, please look at their respective docstrings.

Action Wrappers

  • FlattenedActionWrapper
  • DiscretizedActionWrapper
  • RescaledActionWrapper
  • ToScalarActionWrapper
  • RepeatActionWrapper

Observation Wrappers

  • FlattenedObservationWrapper
  • DiscretizedObservationWrapper
  • RescaledObservationWrapper
  • StackObservationWrapper

Misc

  • ContinuingEnvWrapper

Usage Example

Suppose you want to train a (D)DQN agent for an environment with continuous actions. Since DQN implementations typically expect to produce a single discrete action, the action space has to both be discretized and flattened, as demonstrated in the code below.

import gym
import space_wrappers
# An environment with a continuous action space.
# We first turn it into a MultiDiscrete, and then into
# a flat discrete action space.
env = gym.make("LunarLanderContinuous-v2")
wrapped = space_wrappers.DiscretizedActionWrapper(env, 3)
wrapped = space_wrappers.FlattenedActionWrapper(wrapped)

# this is now a single integer
print(wrapped.action_space.sample())

TODO

  • Documentation
  • Handle Tuple spaces
  • More Sanity checks
  • Image transformations (resample, resize, ...)
  • Array Transformations (reshape)
  • allow pickling of wrapped envs + corresponding tests

About

General purpose environment wrappers for openai gym

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages