PairREInteraction¶
- class PairREInteraction(p, power_norm=False)[source]¶
Bases:
pykeen.nn.modules.TranslationalInteraction[torch.FloatTensor,Tuple[torch.FloatTensor,torch.FloatTensor],torch.FloatTensor]A stateful module for the PairRE 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.
Attributes Summary
The symbolic shapes for relation representations
Methods Summary
func(t, r_h, r_t[, p, power_norm])Evaluate the PairRE interaction function.
Attributes Documentation
Methods Documentation
- func(t, r_h, r_t, p=2, power_norm=True)¶
Evaluate the PairRE interaction function.
\[-\|h \odot r_h - t \odot r_t \|\]- Parameters
h (
FloatTensor) – shape: (batch_size, num_heads, 1, 1, dim) The head representations.t (
FloatTensor) – shape: (batch_size, 1, 1, num_tails, dim) The tail representations.r_h (
FloatTensor) – shape: (batch_size, 1, num_relations, 1, dim) The head part of the relation representations.r_t (
FloatTensor) – shape: (batch_size, 1, num_relations, 1, dim) The tail part of the relation representations.p (
Union[int,str]) – The parameter p for selecting the 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.