noether.data.pipeline.batch_processors.moment_normalization¶
Classes¶
Normalizes a value with its mean and standard deviation (i.e., its moments) in a batch. |
Module Contents¶
- class noether.data.pipeline.batch_processors.moment_normalization.MomentNormalizationBatchProcessor(items, mean, std)¶
Bases:
noether.data.pipeline.batch_processor.BatchProcessorNormalizes a value with its mean and standard deviation (i.e., its moments) in a batch.
Example:
processor = MomentNormalizationBatchProcessor( items=['velocity', 'pressure'], mean=[1.0, 2.0], std=[0.1, 0.2], ) batch = { 'velocity': torch.tensor([[.., ..], [.., ..]]), 'pressure': torch.tensor([[.., ..], [.., ..]]), } normalized_batch = processor(batch) # normalized_batch['velocity'] will be tensor([[.., ..], [.., ..]]) # normalized_batch['pressure'] will be tensor([[.., ..], [.., ..]])
- Parameters:
mean (collections.abc.Sequence[float]) – the mean of the value.
std (collections.abc.Sequence[float]) – the standard deviation of the value.
- items¶
- mean_tensor¶
- std_tensor¶
- denormalize(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)