kg2e_interaction¶
-
kg2e_interaction
(h_mean, h_var, r_mean, r_var, t_mean, t_var, similarity='KL', exact=True)[source]¶ Evaluate the KG2E interaction function.
- Parameters
h_mean (
FloatTensor
) – shape: (batch_size, num_heads, 1, 1, d) The head entity distribution mean.h_var (
FloatTensor
) – shape: (batch_size, num_heads, 1, 1, d) The head entity distribution variance.r_mean (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, d) The relation distribution mean.r_var (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, d) The relation distribution variance.t_mean (
FloatTensor
) – shape: (batch_size, 1, 1, num_tails, d) The tail entity distribution mean.t_var (
FloatTensor
) – shape: (batch_size, 1, 1, num_tails, d) The tail entity distribution variance.similarity (
str
) – The similarity measures for gaussian distributions. From {“KL”, “EL”}.exact (
bool
) – Whether to leave out constants to accelerate similarity computation.
- Return type
FloatTensor
- Returns
shape: (batch_size, num_heads, num_relations, num_tails) The scores.