yamle.utils.operation_utils module#
- yamle.utils.operation_utils.average_predictions(predictions, task, weights=None)[source]#
This function is used to average the predictions.
Note that it is assumed that no gradients are passed through the predictions when this function is called.
- yamle.utils.operation_utils.weighted_regression_variance(predictions, weights=None)[source]#
This function is used to calculate the regression variance.
- Parameters:
- Return type:
Tensor
- yamle.utils.operation_utils.repeat_inputs(inputs, num)[source]#
This method is used to concatenate the num inputs into the first dimension.
- Return type:
Tensor
- yamle.utils.operation_utils.repeat_inputs_in_batch(batch, num)[source]#
This method is used to concatenate the num dimension into the batch dimension.
- Return type:
List[Tensor]
- yamle.utils.operation_utils.entropy(probabilities, dim=1)[source]#
Compute the entropy of a probability distribution. :type _sphinx_paramlinks_yamle.utils.operation_utils.entropy.probabilities:
Tensor:param _sphinx_paramlinks_yamle.utils.operation_utils.entropy.probabilities: The probability distribution. :type _sphinx_paramlinks_yamle.utils.operation_utils.entropy.probabilities: torch.Tensor :type _sphinx_paramlinks_yamle.utils.operation_utils.entropy.dim:int:param _sphinx_paramlinks_yamle.utils.operation_utils.entropy.dim: The dimension to compute the entropy. Defaults to 1. :type _sphinx_paramlinks_yamle.utils.operation_utils.entropy.dim: int, optional- Return type:
Tensor- Returns:
torch.Tensor – The entropy of the distribution.
- yamle.utils.operation_utils.classification_uncertainty_decomposition(samples, probabilities=False, weights=None)[source]#
Decompose the output with repsect to predictive, aleatoric and epistemic uncertainties.
- Parameters:
samples¶ (torch.Tensor) – The samples to decompose. The shape should be (batch_size, num_members, num_classes).
probabilities¶ (bool, optional) – Whether the samples are probabilities. Defaults to False.
weights¶ (Optional[torch.Tensor], optional) – The weights to use for the decomposition. Defaults to None.
- Return type:
Tuple[Tensor,Tensor,Tensor]