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.

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:

normalizer_config (noether.core.schemas.normalizers.ShiftAndScaleNormalizerConfig) – Configuration containing shift and scale values.

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.

shift: torch.Tensor | None = None
scale: torch.Tensor | None = None
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:
  • normalizer_config (noether.core.schemas.normalizers.MeanStdNormalizerConfig) – Configuration containing mean and std values. Imports MeanStdNormalizerConfig.

  • **kwargs – Additional arguments passed to the parent class.

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:
  • normalizer_config (noether.core.schemas.normalizers.PositionNormalizerConfig) – Configuration containing raw position min, max, and scale values.

  • **kwargs – Additional arguments passed to the parent class.

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