noether.data.pipeline.batch_processors¶
Submodules¶
Classes¶
Normalizes a value with its mean and standard deviation (i.e., its moments) in a batch. |
|
Post-processes data on a batch-level to normalize positions. |
|
Utility processor that simply renames the dictionary keys in a batch. |
Package Contents¶
- class noether.data.pipeline.batch_processors.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)
- class noether.data.pipeline.batch_processors.PositionNormalizationBatchProcessor(items, raw_pos_min, raw_pos_max, scale=1000)¶
Bases:
noether.data.pipeline.batch_processor.BatchProcessorPost-processes data on a batch-level to normalize positions.
- Parameters:
items (list[str]) – The position items (i.e., keys in the batch) to normalize.
raw_pos_min (collections.abc.Sequence[float]) – The minimum position in the source domain.
raw_pos_max (collections.abc.Sequence[float]) – The maximum position in the source domain.
scale (int | float) – The maximum value of the position. Defaults to 1000.
- items¶
- scale = 1000¶
- raw_pos_min_tensor¶
- raw_pos_max_tensor¶
- raw_size¶
- 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)
- class noether.data.pipeline.batch_processors.RenameKeysBatchProcessor(key_map)¶
Bases:
noether.data.pipeline.batch_processor.BatchProcessorUtility processor that simply renames the dictionary keys in a batch. Rename keys in the batch if they are in the key_map and keep old keys otherwise. Creates a new dictionary whose keys are renamed but uses references to the values of the old dict. This avoids copying the data and at the same time does not modify this function’s input.
- Parameters:
key_map (dict[str, str]) – dict with source keys as keys and target keys as values. The source keys are renamed target keys.
- key_map¶
- denormalize(key, value)¶
Inverts the key mapping from the __call__ method.
- Parameters:
key (str) – The name of the item.
value (torch.Tensor) – The value of the item.
- Returns:
The (potentially) remapped name and the unchanged value.
- Return type:
(key, value)