predict_uncertain_helper
- predict_uncertain_helper(model: Model, batch: Tensor, score_method: Callable[[...], Tensor], num_samples: int, slice_size: int | None = None, *, mode: Literal['training', 'validation', 'testing'] | None) UncertainPrediction [source]
Predict with uncertainty estimates via Monte-Carlo dropout.
- Parameters:
model (Model) – the model used for predicting scores
batch (Tensor) – the batch on which to predict. Its shape and content has to match what the score_method requires.
score_method (Callable[[...], Tensor]) – the base score method to use (from score_{hrt,h,r,t})
num_samples (int) – >1 The number of samples to use. More samples lead to better estimates, but increase memory requirements and runtime.
slice_size (int | None) – >0 The divisor for the scoring function when using slicing.
mode (Literal['training', 'validation', 'testing'] | None) – The pass mode, which is None in the transductive setting and one of “training”, “validation”, or “testing” in the inductive setting.
- Returns:
A tuple (score_mean, score_std) of the mean and std of the scores sampled from the dropout distribution. The std may be interpreted as a measure of uncertainty.
- Raises:
MissingDropoutError – if the model does not contain dropout layers.
- Return type:
Warning
This function sets the model to evaluation mode and all dropout layers to training mode.