predict_t_uncertain
- predict_t_uncertain(model: Model, hr_batch: Tensor, num_samples: int = 5, slice_size: int | None = None, *, mode: Literal['training', 'validation', 'testing'] | None = None) UncertainPrediction [source]
Forward pass using right side (tail) prediction for obtaining scores of all possible tails.
This method calculates the score for all possible tails for each (head, relation) pair, as well as an uncertainty quantification.
Note
We only expect the right side predictions, i.e., \((h,r,*)\) to change its default behavior when the model has been trained with inverse relations (mainly because of the behavior of the LCWA training approach). This is why the
predict_h_uncertain()
has different behavior depending on if inverse triples were used in training, and why this function has the same behavior regardless of the use of inverse triples.- Parameters:
model (Model) – the model used for predicting scores
hr_batch (Tensor) – shape: (batch_size, 2) The indices of (head, relation) pairs.
slice_size (int | None) – >0 The divisor for the scoring function when using slicing.
num_samples (int) – >1 the number of samples to draw
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:
shape: (batch_size, num_entities) For each h-r pair, the scores for all possible tails.
This function delegates to
predict_uncertain_helper()
by usingpykeen.models.Model.score_t()
as thescore_method
.- Return type:
Warning
This function sets the model to evaluation mode and all dropout layers to training mode.