mighty.utils.var_online.VarianceOnlineBatch¶
- class mighty.utils.var_online.VarianceOnlineBatch(tensor=None)[source]¶
Welford’s online algorithm for population mean and variance estimation from batches of 1d vectors.
Methods
__init__
([tensor])activate
(is_active)Activates or deactivates the updates.
get_mean
()- Returns:
get_mean_std
([unbiased])Return mean and std of all samples.
reset
()Reset the mean and the count.
update
(tensor)Update sample mean (and variance) from a batch of new values.
- activate(is_active)¶
Activates or deactivates the updates.
- Parameters:
- is_activebool
New state.
- get_mean()¶
- Returns:
- torch.Tensor
The mean of all tensors.
- get_mean_std(unbiased=True)¶
Return mean and std of all samples.
- Parameters:
- unbiasedbool, optional
Biased (False) or unbiased (True) variance estimate. Default: True
- Returns:
- meantorch.Tensor
The mean of all samples.
- stdtorch.Tensor
The std of all samples.
- reset()¶
Reset the mean and the count.