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_dims, dim) The head representations.

  • w_r (FloatTensor) – shape: (*batch_dims, dim) The relation normal vector representations.

  • d_r (FloatTensor) – shape: (*batch_dims, dim) The relation difference vector representations.

  • t (FloatTensor) – shape: (*batch_dims, dim) The tail representations.

  • p (int) – The p for the norm. cf. torch.linalg.vector_norm().

  • power_norm (bool) – Whether to return \(|x-y|_p^p\).

Return type

FloatTensor

Returns

shape: batch_dims The scores.