TransRInteraction
- class TransRInteraction(p, power_norm=True)[source]
Bases:
pykeen.nn.modules.NormBasedInteraction
[torch.FloatTensor
,Tuple
[torch.FloatTensor
,torch.FloatTensor
],torch.FloatTensor
]A stateful module for the TransR interaction function.
Initialize the norm-based interaction function.
- Parameters
p (
int
) – The norm used withtorch.linalg.vector_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
(r, t, m_r, p[, power_norm])Evaluate the TransR interaction function.
Attributes Documentation
Methods Documentation
- func(r, t, m_r, p, power_norm=True)
Evaluate the TransR interaction function.
- Parameters
h (
FloatTensor
) – shape: (*batch_dims, d_e) Head embeddings.r (
FloatTensor
) – shape: (*batch_dims, d_r) Relation embeddings.m_r (
FloatTensor
) – shape: (*batch_dims, d_e, d_r) The relation specific linear transformations.t (
FloatTensor
) – shape: (*batch_dims, d_e) Tail embeddings.p (
int
) – The parameter p for selecting the norm.power_norm (
bool
) – Whether to return the powered norm instead.
- Return type
FloatTensor
- Returns
shape: batch_dims The scores.