sinergym.utils.wrappers.NormalizeObservation
- class sinergym.utils.wrappers.NormalizeObservation(env: Env, automatic_update: bool = True, epsilon: float = 1e-08, mean: list | float64 | str = None, var: list | float64 | str = None)
- __init__(env: Env, automatic_update: bool = True, epsilon: float = 1e-08, mean: list | float64 | str = None, var: list | float64 | str = None)
Initializes the NormalizationWrapper. Mean and var values can be None and being updated during interaction with environment.
- Parameters:
env (Env) – The environment to apply the wrapper.
automatic_update (bool, optional) – Whether or not to update the mean and variance values automatically. Defaults to True.
epsilon (float, optional) – A stability parameter used when scaling the observations. Defaults to 1e-8.
mean (list, np.float64, str, optional) – The mean value used for normalization. It can be a mean.txt path too. Defaults to None.
var (list, np.float64, str, optional) – The variance value used for normalization. It can be a var.txt path too. Defaults to None.
Methods
__init__(env[, automatic_update, epsilon, ...])Initializes the NormalizationWrapper.
Activates the automatic update of the normalization wrapper.
class_name()Returns the class name of the wrapper.
close()Close the environment and save normalization calibration.
Deactivates the automatic update of the normalization wrapper.
get_wrapper_attr(name)Gets an attribute from the wrapper and lower environments if name doesn't exist in this object.
has_wrapper_attr(name)Checks if the given attribute is within the wrapper or its environment.
normalize(obs)Normalizes the observation using the running mean and variance of the observations.
render()Uses the
render()of theenvthat can be overwritten to change the returned data.reset(**kwargs)Resets the environment and normalizes the observation.
set_mean(mean)Sets the mean value of the observations.
set_var(var)Sets the variance value of the observations.
set_wrapper_attr(name, value, *[, force])Sets an attribute on this wrapper or lower environment if name is already defined.
step(action)Steps through the environment and normalizes the observation.
wrapper_spec(**kwargs)Generates a WrapperSpec for the wrappers.
Attributes
action_spaceReturn the
Envaction_spaceunless overwritten then the wrapperaction_spaceis used.Returns the mean value of the observations.
metadataReturns the
Envmetadata.np_randomReturns the
Envnp_randomattribute.np_random_seedReturns the base environment's
np_random_seed.observation_spaceReturn the
Envobservation_spaceunless overwritten then the wrapperobservation_spaceis used.render_modeReturns the
Envrender_mode.specReturns the
Envspecattribute with the WrapperSpec if the wrapper inherits from EzPickle.unwrappedReturns the base environment of the wrapper.
Returns the variance value of the observations.
- activate_update()
Activates the automatic update of the normalization wrapper. After calling this method, the normalization wrapper will update its calibration automatically.
- close()
Close the environment and save normalization calibration.
- deactivate_update()
Deactivates the automatic update of the normalization wrapper. After calling this method, the normalization wrapper will not update its calibration automatically.
- logger = <Logger WRAPPER NormalizeObservation (INFO)>
- property mean: float64 | None
Returns the mean value of the observations.
- normalize(obs)
Normalizes the observation using the running mean and variance of the observations. If automatic_update is enabled, the running mean and variance will be updated too.
- reset(**kwargs)
Resets the environment and normalizes the observation.
- set_mean(mean: list | float64 | str)
Sets the mean value of the observations.
- set_var(var: list | float64 | str)
Sets the variance value of the observations.
- step(action: int | ndarray) Tuple[ndarray, float, bool, bool, Dict[str, Any]]
Steps through the environment and normalizes the observation.
- property var: float64 | None
Returns the variance value of the observations.