noether.data.preprocessors.normalizers¶
Classes¶
Preprocessor that shifts and scales the input data, with (x + shift) * scale. |
|
Normalizes data using mean and standard deviation. It shifts the data by subtracting the mean and scales it by dividing by the standard deviation. |
|
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. |
|
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.PreProcessorPreprocessor 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. See
ShiftAndScaleNormalizerConfigfor details.**kwargs – Additional arguments passed to the parent class.
- 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:
- class noether.data.preprocessors.normalizers.MeanStdNormalization(normalizer_config, **kwargs)¶
Bases:
ShiftAndScaleNormalizerNormalizes 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. See
MeanStdNormalizerConfigfor details.**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:
ShiftAndScaleNormalizerNormalizes 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. See
PositionNormalizerConfigfor details.**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¶
- class noether.data.preprocessors.normalizers.FieldNormalizer(normalizer_config, statistics, **kwargs)¶
Bases:
noether.data.preprocessors.PreProcessorPreprocessor that normalizes a field based on a specified strategy and dataset statistics.
- Parameters:
normalizer_config (noether.core.schemas.normalizers.FieldNormalizerConfig) – Configuration containing the normalization strategy and logscale flag. See
FieldNormalizerConfigfor details.statistics (dict[str, list[float | int] | float | int] | None) – A dictionary containing the dataset statistics needed for normalization (e.g., mean, std, raw_pos_min, raw_pos_max).
**kwargs – Additional arguments passed to the parent class.
- 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: