garage.envs.normalized_env

An environment wrapper that normalizes action, observation and reward.

class NormalizedEnv(env, scale_reward=1.0, normalize_obs=False, normalize_reward=False, expected_action_scale=1.0, flatten_obs=True, obs_alpha=0.001, reward_alpha=0.001)

Bases: garage.Wrapper

Inheritance diagram of garage.envs.normalized_env.NormalizedEnv

An environment wrapper for normalization.

This wrapper normalizes action, and optionally observation and reward.

Parameters
  • env (Environment) – An environment instance.

  • scale_reward (float) – Scale of environment reward.

  • normalize_obs (bool) – If True, normalize observation.

  • normalize_reward (bool) – If True, normalize reward. scale_reward is applied after normalization.

  • expected_action_scale (float) – Assuming action falls in the range of [-expected_action_scale, expected_action_scale] when normalize it.

  • flatten_obs (bool) – Flatten observation if True.

  • obs_alpha (float) – Update rate of moving average when estimating the mean and variance of observations.

  • reward_alpha (float) – Update rate of moving average when estimating the mean and variance of rewards.

property action_space

The action space specification.

Type

akro.Space

property observation_space

The observation space specification.

Type

akro.Space

property spec

The environment specification.

Type

EnvSpec

property render_modes

A list of string representing the supported render modes.

Type

list

property unwrapped

The inner environment.

Type

garage.Environment

reset()

Call reset on wrapped env.

Returns

The first observation conforming to

observation_space.

dict: The episode-level information.

Note that this is not part of env_info provided in step(). It contains information of he entire episode, which could be needed to determine the first action (e.g. in the case of goal-conditioned or MTRL.)

Return type

numpy.ndarray

step(action)

Call step on wrapped env.

Parameters

action (np.ndarray) – An action provided by the agent.

Returns

The environment step resulting from the action.

Return type

EnvStep

Raises

RuntimeError – if step() is called after the environment has been constructed and reset() has not been called.

render(mode)

Render the wrapped environment.

Parameters

mode (str) – the mode to render with. The string must be present in self.render_modes.

Returns

the return value for render, depending on each env.

Return type

object

visualize()

Creates a visualization of the wrapped environment.

close()

Close the wrapped env.

normalize