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

  • Title: Updating Formulae and a Pairwise Algorithm for Computing Sample Variances

  • Author: Tony F. Chan, Gene H. Golub, Randall J. LeVeque

  • URL: Normalizer

Initialize an instance of Normalizer.

_push(raw_data)[source]#

Update the mean and std by the raw_data.

Parameters:

raw_data (torch.Tensor) – The raw data to be normalized.

Return type:

None

forward(data)[source]#

Normalize the data.

Parameters:

data (torch.Tensor) – The raw data to be normalized.

Returns:

The normalized data.

Return type:

Tensor

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

Load the state_dict to the normalizer.

Parameters:
  • state_dict (Mapping[str, Any]) – The state_dict to be loaded.

  • strict (bool, optional) – Whether to strictly enforce that the keys in state_dict. Defaults to True.

Returns:

The loaded normalizer.

Return type:

Any

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 (torch.Tensor) – The raw data to be normalized.

Returns:

The normalized data.

Return type:

Tensor

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

Return the shape of the normalize.

property std: Tensor#

Return the std of the normalize.