TransEInteraction
- class TransEInteraction(p, power_norm=False)[source]
Bases:
NormBasedInteraction
[FloatTensor
,FloatTensor
,FloatTensor
]A stateful module for the TransE 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.
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_dims, dim) The head representations.r (
FloatTensor
) – shape: (*batch_dims, dim) The relation representations.t (
FloatTensor
) – shape: (*batch_dims, dim) The tail representations.power_norm (
bool
) – Whether to return the powered norm.
- Return type:
FloatTensor
- Returns:
shape: batch_dims The scores.