transh_interaction¶
-
transh_interaction
(h, w_r, d_r, t, p, power_norm=False)[source]¶ Evaluate the DistMult interaction function.
- Parameters
h (
FloatTensor
) – shape: (batch_size, num_heads, 1, 1, dim) The head representations.w_r (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, dim) The relation normal vector representations.d_r (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, dim) The relation difference vector representations.t (
FloatTensor
) – shape: (batch_size, 1, 1, num_tails, dim) The tail representations.p (
int
) – The p for the norm. cf. torch.norm.power_norm (
bool
) – Whether to return \(|x-y|_p^p\).
- Return type
FloatTensor
- Returns
shape: (batch_size, num_heads, num_relations, num_tails) The scores.