mighty.utils.var_online.MeanOnline

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

Online sample mean aggregate. Works with scalars, vectors, and n-dimensional tensors.

Parameters:
tensortorch.Tensor or None

The initial tensor, if provided.

Methods

__init__([tensor])

activate(is_active)

Activates or deactivates the updates.

get_mean()

Returns:

reset()

Reset the mean and the count.

update(tensor)

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

activate(is_active)[source]

Activates or deactivates the updates.

Parameters:
is_activebool

New state.

get_mean()[source]
Returns:
torch.Tensor

The mean of all tensors.

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.