noether.data.pipeline.sample_processors.moment_normalization¶
Classes¶
Normalizes a value with its mean and standard deviation (i.e., its moments). |
Module Contents¶
- class noether.data.pipeline.sample_processors.moment_normalization.MomentNormalizationSampleProcessor(item, mean=None, std=None, logmean=None, logstd=None, logscale=False)¶
Bases:
noether.data.pipeline.sample_processor.SampleProcessorNormalizes a value with its mean and standard deviation (i.e., its moments).
# dummy example processor = MomentNormalizationSampleProcessor( item="measurement", mean=[10.0], std=[2.0], logscale=False, ) input_sample = { "measurement": torch.tensor([[12.0], [14.0], [8.0]]), "other_item": torch.tensor([[1.0], [2.0], [3.0]]), } output_sample = processor(input_sample) # output_sample['measurement'] will be tensor([[1.0], [2.0], [-1.0]]) # output_sample['other_item'] will be unchanged.
- Parameters:
item (str) – The item (i.e., key in the input sample dictionary) to normalize.
mean (collections.abc.Sequence[float] | None) – The mean of the value. Mandatory if logscale=False.
std (collections.abc.Sequence[float] | None) – The standard deviation of the value. Mandatory if logscale=False.
logmean (collections.abc.Sequence[float] | None) – The mean of the value in logscale. Mandatory if logscale=True.
logstd (collections.abc.Sequence[float] | None) – The standard deviation of the value in logscale. Mandatory if logscale=True.
logscale (bool) – Whether to convert the value to logscale before normalization.
- item¶
- mean_tensor = None¶
- std_tensor = None¶
- logmean_tensor = None¶
- logstd_tensor = None¶
- logscale = False¶
- inverse(key, value)¶
Inverts the normalization from the __call__ method of a single item in the batch.
- Parameters:
key (str) – The name of the item.
value (torch.Tensor) – The value of the item.
- Returns:
The same name and the denormalized value.
- Return type:
(key, value)