mure_interaction

mure_interaction(h, b_h, r_vec, r_mat, t, b_t, p=2, power_norm=False)[source]

Evaluate the MuRE interaction function from [balazevic2019b].

\[-\|Rh + r - t\| + b_h + b_t\]
Parameters
  • h (FloatTensor) – shape: (batch_size, num_heads, 1, 1, dim) The head representations.

  • b_h (FloatTensor) – shape: (batch_size, num_heads, 1, 1) The head entity bias.

  • r_vec (FloatTensor) – shape: (batch_size, 1, num_relations, 1, dim) The relation vector.

  • r_mat (FloatTensor) – shape: (batch_size, 1, num_relations, 1, dim,) The diagonal relation matrix.

  • t (FloatTensor) – shape: (batch_size, 1, 1, num_tails, dim) The tail representations.

  • b_t (FloatTensor) – shape: (batch_size, 1, 1, num_tails) The tail entity bias.

  • p (Union[int, float, str]) – The parameter p for selecting the norm, cf. torch.norm.

  • power_norm (bool) – Whether to return the powered norm instead.

Return type

FloatTensor

Returns

shape: (batch_size, num_heads, num_relations, num_tails) The scores.