Skip to content

lit_sb3.wrappers.time_feature

source module lit_sb3.wrappers.time_feature

Classes

  • TimeFeatureWrapper — Add remaining, normalized time to observation space for fixed length episodes.

source class TimeFeatureWrapper(env: gym.Env, max_steps: int = 1000, test_mode: bool = False)

Bases : gym.Wrapper[TimeFeatureObs, ActType, TimeFeatureObs, ActType]

Add remaining, normalized time to observation space for fixed length episodes.

See https://arxiv.org/abs/1712.00378 and https://github.com/aravindr93/mjrl/issues/13.

.. note::

Only ``gym.spaces.Box`` and ``gym.spaces.Dict`` (``gym.GoalEnv``) 1D observation spaces
are supported for now.

Parameters

  • env : gym.Env — Gym env to wrap.

  • max_steps : int — Max number of steps of an episode if it is not wrapped in a TimeLimit object.

  • test_mode : bool — In test mode, the time feature is constant, equal to zero. This allow to check that the agent did not overfit this feature, learning a deterministic pre-defined sequence of actions.

Attributes

  • metadata : dict[str, Any] — attr:Env :attr:metadata.

  • render_mode : str | None — attr:Env :attr:render_mode.

  • spec : EnvSpec | None — attr:Env :attr:spec attribute with the WrapperSpec if the wrapper inherits from EzPickle.

  • action_space : spaces.Space[ActType] | spaces.Space[WrapperActType] — attr:Env :attr:action_space unless overwritten then the wrapper :attr:action_space is used.

  • observation_space : spaces.Space[ObsType] | spaces.Space[WrapperObsType] — attr:Env :attr:observation_space unless overwritten then the wrapper :attr:observation_space is used.

  • unwrapped : Env[ObsType, ActType] — Returns the base environment of the wrapper.

  • np_random_seed : int | None — attr:np_random_seed.

  • np_random : np.random.Generator — attr:Env :attr:np_random attribute.

Methods

source method TimeFeatureWrapper.reset(**kwargs) → tuple[TimeFeatureObs, dict[str, Any]]

source method TimeFeatureWrapper.step(action: ActType) → tuple[TimeFeatureObs, SupportsFloat, bool, bool, dict[str, Any]]