TransEInteraction¶
-
class
TransEInteraction(p, power_norm=False)[source]¶ Bases:
pykeen.nn.modules.TranslationalInteraction[torch.FloatTensor,torch.FloatTensor,torch.FloatTensor]A stateful module for the TransE interaction function.
Initialize the translational interaction function.
- Parameters
p (
int) – The norm used withtorch.norm(). Typically is 1 or 2.power_norm (
bool) – Whether to use the p-th power of the L_p norm. It has the advantage of being differentiable around 0, and numerically more stable.
Methods Summary
func(r, t[, p, power_norm])Evaluate the TransE interaction function.
Methods Documentation
-
func(r, t, p=2, power_norm=False)¶ Evaluate the TransE interaction function.
- Parameters
h (
FloatTensor) – shape: (batch_size, num_heads, 1, 1, dim) The head representations.r (
FloatTensor) – shape: (batch_size, 1, num_relations, 1, dim) The relation representations.t (
FloatTensor) – shape: (batch_size, 1, 1, num_tails, dim) The tail representations.power_norm (
bool) – Whether to return the powered norm.
- Return type
FloatTensor- Returns
shape: (batch_size, num_heads, num_relations, num_tails) The scores.