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.
normalize
(obs)Normalizes the observation using the running mean and variance of the observations.
render
()Uses the
render()
of theenv
that 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.
step
(action)Steps through the environment and normalizes the observation.
wrapper_spec
(**kwargs)Generates a WrapperSpec for the wrappers.
Attributes
action_space
Return the
Env
action_space
unless overwritten then the wrapperaction_space
is used.Returns the mean value of the observations.
metadata
Returns the
Env
metadata
.np_random
Returns the
Env
np_random
attribute.observation_space
Return the
Env
observation_space
unless overwritten then the wrapperobservation_space
is used.render_mode
Returns the
Env
render_mode
.reward_range
Return the
Env
reward_range
unless overwritten then the wrapperreward_range
is used.spec
Returns the
Env
spec
attribute with the WrapperSpec if the wrapper inherits from EzPickle.unwrapped
Returns 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.