triple_re_interaction
- triple_re_interaction(h, r_head, r_mid, r_tail, t, u=None, p=2, power_norm=False)[source]
Evaluate the TripleRE interaction function.
\[score(h, (r_h, r, r_t), t) = h * (r_h + u) - t * (r_t + u) + r\]Note
For equivalence to the paper version, h and t should be normalized to unit Euclidean length, and p and power_norm be kept at their default values.
- Parameters
h (
FloatTensor
) – shape: (*batch_dims, rank, dim) The head representations.r_head (
FloatTensor
) – shape: (*batch_dims, rank, dim) The relation-specific head multiplicator representations.r_mid (
FloatTensor
) – shape: (*batch_dims, rank, dim) The relation representations.r_tail (
FloatTensor
) – shape: (*batch_dims, rank, dim) The relation-specific tail multiplicator representations.t (
FloatTensor
) – shape: (*batch_dims, rank, dim) The tail representations.u (
Optional
[float
]) – the relation factor offset. If u is not None or 0, this corresponds to TripleREv2.p (
int
) – The p for the norm. cf.torch.linalg.vector_norm()
.power_norm (
bool
) – Whether to return the powered norm.
- Return type
FloatTensor
- Returns
shape: batch_dims The scores.