mighty.utils.var_online.VarianceOnline

class mighty.utils.var_online.VarianceOnline(tensor=None)[source]

Welford’s online algorithm for population mean and variance estimation.

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)[source]

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()[source]

Reset the mean and the count.

update(tensor)[source]

Update sample mean (and variance) from a batch of new values.

Parameters:
tensortorch.Tensor

Next tensor sample.