OmniSafe Normalizer#

Normalizer(shape[, clip])

Calculate normalized raw_data from running mean and std

Normalizer#

Documentation

class omnisafe.common.normalizer.Normalizer(shape, clip=1e6)[source]#

Calculate normalized raw_data from running mean and std

References

Initialize the normalize.

__init__(shape, clip=1e6)[source]#

Initialize the normalize.

_push(raw_data)[source]#

Update the mean and std by the raw_data.

Parameters:

raw_data (Tensor) – raw data to be normalized.

Return type:

None

forward(data)[source]#

Normalize the data.

Return type:

Tensor

load_state_dict(state_dict, strict=True)[source]#

Copies parameters and buffers from state_dict into this module and its descendants. If strict is True, then the keys of state_dict must exactly match the keys returned by this module’s state_dict() function.

Parameters:
  • state_dict (dict) – a dict containing parameters and persistent buffers.

  • strict (bool, optional) – whether to strictly enforce that the keys in state_dict match the keys returned by this module’s state_dict() function. Default: True

Returns:

``NamedTuple`` with ``missing_keys`` and ``unexpected_keys`` fields

  • missing_keys is a list of str containing the missing keys

  • unexpected_keys is a list of str containing the unexpected keys

Note

If a parameter or buffer is registered as None and its corresponding key exists in state_dict, load_state_dict() will raise a RuntimeError.

property mean: Tensor#

Return the mean of the normalize.

normalize(data)[source]#

Normalize the data.

Hint

  • If the data is the first data, the data will be used to initialize the mean and std.

  • If the data is not the first data, the data will be normalized by the mean and std.

  • Update the mean and std by the data.

Parameters:

data (Tensor) – raw data to be normalized.

Return type:

Tensor

property shape: Tuple[int, ...]#

Return the shape of the normalize.

property std: Tensor#

Return the std of the normalize.