noether.data.preprocessors.normalizers

Classes

ShiftAndScaleNormalizer

Preprocessor that shifts and scales the input data, with (x + shift) * scale.

MeanStdNormalization

Normalizes data using mean and standard deviation. It shifts the data by subtracting the mean and scales it by dividing by the standard deviation.

PositionNormalizer

Normalizes position data to a range of [0, scale]. It inherits from ShiftAndScaleNormalizer and applies a shift and scale based on the provided raw position min and max values.

FieldNormalizer

Preprocessor that normalizes a field based on a specified strategy and dataset statistics.

Module Contents

class noether.data.preprocessors.normalizers.ShiftAndScaleNormalizer(normalizer_config, **kwargs)

Bases: noether.data.preprocessors.PreProcessor

Preprocessor that shifts and scales the input data, with (x + shift) * scale.

Parameters:
Raises:
  • ValueError – If shift and scale do not have the same length.

  • ValueError – If logscale_shift and logscale_scale do not have the same length when logscale is True.

  • TypeError – If shift, scale, logscale_shift, or logscale_scale are not of type Sequence or torch.Tensor.

  • ValueError – If scale contains zero values (to avoid division by zero).

  • ValueError – If scale contains negative values.

  • ValueError – If shift and scale are provided but not both.

scale
shift
logscale
denormalize(x)

Denormalizes the input data by applying the inverse operation of the normalization.

Parameters:

x (torch.Tensor) – torch.Tensor: The input tensor to denormalize.

Return type:

torch.Tensor

class noether.data.preprocessors.normalizers.MeanStdNormalization(normalizer_config, **kwargs)

Bases: ShiftAndScaleNormalizer

Normalizes data using mean and standard deviation. It shifts the data by subtracting the mean and scales it by dividing by the standard deviation.

Parameters:
Raises:
  • ValueError – If mean and std do not have the same length.

  • ValueError – If any value in std is zero (to avoid division by zero).

  • ValueError – If any value in std is negative.

EPSILON = 1e-06
mean
std
class noether.data.preprocessors.normalizers.PositionNormalizer(normalizer_config, **kwargs)

Bases: ShiftAndScaleNormalizer

Normalizes position data to a range of [0, scale]. It inherits from ShiftAndScaleNormalizer and applies a shift and scale based on the provided raw position min and max values.

Parameters:
Raises:
  • ValueError – If raw_pos_min and raw_pos_max do not have the same length.

  • ValueError – If raw_pos_max is equal to raw_pos_min.

  • ValueError – If scale is not a positive number.

raw_pos_min
raw_pos_max
resizing_scale
class noether.data.preprocessors.normalizers.FieldNormalizer(normalizer_config, statistics, **kwargs)

Bases: noether.data.preprocessors.PreProcessor

Preprocessor that normalizes a field based on a specified strategy and dataset statistics.

Parameters:
Raises:
  • ValueError – If the required statistics for the chosen strategy are not present in the statistics dictionary.

  • ValueError – If the normalization strategy is not supported.

normalizer: noether.data.preprocessors.PreProcessor
denormalize(x)

Denormalizes the input data. This method should be overridden by subclasses if denormalization is supported. If denormalization is not supported, it raises NotImplementedError or decide to implement the identity function.

Parameters:

x (torch.Tensor) – The input tensor to denormalize.

Return type:

torch.Tensor