structured_embedding_interaction¶
-
structured_embedding_interaction
(h, r_h, r_t, t, p, power_norm=False)[source]¶ Evaluate the Structured Embedding interaction function.
\[f(h, r, t) = -\|R_h h - R_t t\|\]- Parameters
h (
FloatTensor
) – shape: (batch_size, num_heads, 1, 1, dim) The head representations.r_h (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, rel_dim, dim) The relation-specific head projection.r_t (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, rel_dim, dim) The relation-specific tail projection.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 the powered norm.
- Return type
FloatTensor
- Returns
shape: (batch_size, num_heads, num_relations, num_tails) The scores.