predict_uncertain_helper
- predict_uncertain_helper(model, batch, score_method, num_samples, slice_size=None, *, mode)[source]
Predict with uncertainty estimates via Monte-Carlo dropout.
- Parameters:
model (
Model
) – the model used for predicting scoresbatch (
LongTensor
) – the batch on which to predict. Its shape and content has to match what the score_method requires.score_method (
Callable
[…,FloatTensor
]) – 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 (
Optional
[int
]) – >0 The divisor for the scoring function when using slicing.mode (
Optional
[Literal
[‘training’, ‘validation’, ‘testing’]]) – The pass mode, which is None in the transductive setting and one of “training”, “validation”, or “testing” in the inductive setting.
- Return type:
- 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.
Warning
This function sets the model to evaluation mode and all dropout layers to training mode.