predict_uncertain_helper(model, batch, score_method, num_samples, slice_size=None, *, mode)[source]

Predict with uncertainty estimates via Monte-Carlo dropout.

  • model (Model) – the model used for predicting scores

  • batch (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:



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.


MissingDropoutError – if the model does not contain dropout layers.


This function sets the model to evaluation mode and all dropout layers to training mode.