predict_h_uncertain
- predict_h_uncertain(model: Model, rt_batch: Tensor, num_samples: int = 5, slice_size: int | None = None, *, mode: Literal['training', 'validation', 'testing'] | None = None) UncertainPrediction [source]
Forward pass using left side (head) prediction for obtaining scores of all possible heads.
This method calculates the score for all possible heads for each (relation, tail) pair, as well as an uncertainty quantification.
Note
If the model has been trained with inverse relations, the task of predicting the head entities becomes the task of predicting the tail entities of the inverse triples, i.e., \(f(*,r,t)\) is predicted by means of \(f(t,r_{inv},*)\).
- Parameters:
model (Model) – the model used for predicting scores
rt_batch (Tensor) – shape: (batch_size, 2) The indices of (relation, tail) 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 r-t pair, the scores for all possible heads.
This function delegates to
predict_uncertain_helper()
by usingpykeen.models.Model.score_h()
(orpykeen.models.Model.score_h_inverse()
if the model uses inverse triples) as thescore_method
.- Return type:
Warning
This function sets the model to evaluation mode and all dropout layers to training mode.