noether.data.stats¶
Classes¶
Calculates running moments of data (mean, variance, min, max) for data normalization purposes. |
|
Calculates statistics of data (min, max, mean and variance) for data normalization purposes. |
Module Contents¶
- class noether.data.stats.RunningMoments(log_scale=False)¶
Bases:
torch.nn.ModuleCalculates running moments of data (mean, variance, min, max) for data normalization purposes.
This class implements Welford’s online algorithm for computing mean and variance in a single pass, making it memory-efficient for large datasets.
Initialize a RunningMoments instance.
- Parameters:
log_scale (bool) – Whether to apply log scaling to the data before calculating moments. This affects all operations unless overridden.
- log_scale = False¶
- push_tensor(x, dim=1, log_scale=None)¶
Add a tensor to the moment calculation. Calculations are carried out in float64 to avoid numerical imprecisions.
- Parameters:
x (torch.Tensor) – Tensor to push. Shape should be compatible with dim parameter.
dim (int) – Which dimension contains the feature dimension. For example: - In a pointcloud (N, 3), dim=1 calculates statistics per coordinate (x, y, z) - In an RGB image (B, C, H, W), dim=1 calculates per-channel statistics
log_scale (bool | None) – Whether to apply log scaling to this tensor. If None, uses the class default.
- Raises:
ValueError – If tensor has invalid dimensions or is incompatible with previous data
- Return type:
None
- push_scalar(x, log_scale=None)¶
Add a scalar to the moment calculation. Calculations are carried out in float64.
- print()¶
Print the calculated statistics in a readable format.
- Return type:
None
- reset()¶
Reset the statistics, clearing all accumulated data.
- Return type:
None
- class noether.data.stats.RunningStats(name=None)¶
Calculates statistics of data (min, max, mean and variance) for data normalization purposes.
- Parameters:
name (str | None)
- name = None¶
- push_tensor(x, dim=1)¶
Add a tensor to the statistics. Calculations are carried out in float64 to avoid numerical imprecision.
- Parameters:
x (torch.Tensor)
dim (int)
- Return type:
None
- property min: torch.Tensor¶
- Return type:
torch.Tensor
- property max: torch.Tensor¶
- Return type:
torch.Tensor
- property mean: torch.Tensor¶
- Return type:
torch.Tensor
- property var: torch.Tensor¶
- Return type:
torch.Tensor
- property std: torch.Tensor¶
- Return type:
torch.Tensor
- property logmean: torch.Tensor¶
- Return type:
torch.Tensor
- property logvar: torch.Tensor¶
- Return type:
torch.Tensor
- property logstd: torch.Tensor¶
- Return type:
torch.Tensor