SEInteraction
- class SEInteraction(p, power_norm=False)[source]
Bases:
NormBasedInteraction[FloatTensor,Tuple[FloatTensor,FloatTensor],FloatTensor]A stateful module for the Structured Embedding (SE) interaction function.
See also
pykeen.nn.functional.structured_embedding_interaction()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_h, r_t, t, p[, power_norm])Evaluate the Structured Embedding interaction function.
Attributes Documentation
Methods Documentation
- func(r_h, r_t, t, p, power_norm=False)
Evaluate the Structured Embedding interaction function.
\[f(h, r, t) = -\|R_h h - R_t t\|\]- Parameters:
h (
FloatTensor) – shape: (*batch_dims, dim) The head representations.r_h (
FloatTensor) – shape: (*batch_dims, rel_dim, dim) The relation-specific head projection.r_t (
FloatTensor) – shape: (*batch_dims, rel_dim, dim) The relation-specific tail projection.t (
FloatTensor) – shape: (*batch_dims, dim) The tail representations.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.