garage.envs.base module

Wrapper class that converts gym.Env into GarageEnv.

class GarageEnv(env=None, env_name='')[source]

Bases: gym.core.Wrapper

Returns an abstract Garage wrapper class for gym.Env.

In order to provide pickling (serialization) and parameterization for gym.Envs, they must be wrapped with a GarageEnv. This ensures compatibility with existing samplers and checkpointing when the envs are passed internally around garage.

Furthermore, classes inheriting from GarageEnv should silently convert action_space and observation_space from gym.Spaces to akro.spaces.

Parameters:
  • env (gym.Env) – An env that will be wrapped
  • env_name (str) – If the env_name is speficied, a gym environment with that name will be created. If such an environment does not exist, a gym.error is thrown.
close()[source]

Close the wrapped env.

reset(**kwargs)[source]

Call reset on wrapped env.

This method is necessary to suppress a deprecated warning thrown by gym.Wrapper.

Parameters:kwargs – Keyword args
Returns:The initial observation.
Return type:object
step(action)[source]

Call step on wrapped env.

This method is necessary to suppress a deprecated warning thrown by gym.Wrapper.

Parameters:action (object) – An action provided by the agent.
Returns:Agent’s observation of the current environment float : Amount of reward returned after previous action bool : Whether the episode has ended, in which case further step()
calls will return undefined results
dict: Contains auxiliary diagnostic information (helpful for
debugging, and sometimes learning)
Return type:object
Step(observation, reward, done, **kwargs)[source]

Create a namedtuple from the results of environment.step(action).

Provides the option to put extra diagnostic info in the kwargs (if it exists) without demanding an explicit positional argument.

Parameters:
  • observation (object) – Agent’s observation of the current environment
  • reward (float) – Amount of reward returned after previous action
  • done (bool) – Whether the episode has ended, in which case further step() calls will return undefined results
  • kwargs – Keyword args
Returns:

A named tuple of the arguments.

Return type:

collections.namedtuple