mighty.utils.var_online.VarianceOnlineLabels¶
- class mighty.utils.var_online.VarianceOnlineLabels[source]¶
Keep track of population mean and std for each unique class label.
Methods
__init__()activate(is_active)Activates or deactivates the updates.
get_mean()get_mean_std([unbiased])Return the mean and std for each unique label individually without the labels themselves.
get_mean_std_labels([unbiased])Return the mean and std for each unique label individually.
labels()reset()Reset the mean and the count.
update(tensor, labels)Update sample mean (and variance) from a batch of new values, split by labels.
- activate(is_active: bool)¶
Activates or deactivates the updates.
- Parameters:
- is_activebool
New state.
- get_mean()¶
- Returns:
- mean_sorted(C, V) torch.Tensor
Mean tensor for each of C unique class labels.
- get_mean_labels()¶
- Returns:
- mean_sorted(C, V) torch.Tensor
Mean tensor for each of C unique class labels.
- labels_sorted(C,) torch.Tensor
Class labels, associated with mean_sorted.
- get_mean_std(unbiased=True)[source]¶
Return the mean and std for each unique label individually without the labels themselves.
- Parameters:
- unbiasedbool, optional
Biased (False) or unbiased (True) variance estimate. Default: True
- Returns:
- mean_sorted(C, V) torch.Tensor
Mean tensor for each of C unique class labels.
- std_sorted(C, V) torch.Tensor
Std tensor for each of C unique class labels.
- get_mean_std_labels(unbiased=True)[source]¶
Return the mean and std for each unique label individually.
- Parameters:
- unbiasedbool, optional
Biased (False) or unbiased (True) variance estimate. Default: True
- Returns:
- mean_sorted(C, V) torch.Tensor
Mean tensor for each of C unique class labels.
- std_sorted(C, V) torch.Tensor
Std tensor for each of C unique class labels.
- labels_sorted(C,) torch.Tensor
Class labels, associated with mean_sorted and std_sorted.
- labels()¶
- Returns:
- list
Unique sorted class labels.
- reset()¶
Reset the mean and the count.
- update(tensor, labels)¶
Update sample mean (and variance) from a batch of new values, split by labels.
- Parameters:
- tensor(B, V) torch.Tensor
A tensor sample.
- labels(B,) torch.Tensor
Batch labels.