TransHInteraction
- class TransHInteraction(p, power_norm=False)[source]
Bases:
NormBasedInteraction
[FloatTensor
,Tuple
[FloatTensor
,FloatTensor
],FloatTensor
]A stateful module for the TransH 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
(w_r, d_r, t, p[, power_norm])Evaluate the DistMult interaction function.
Attributes Documentation
Methods Documentation
- func(w_r, d_r, t, p, power_norm=False)
Evaluate the DistMult interaction function.
- Parameters:
h (
FloatTensor
) – shape: (*batch_dims, dim) The head representations.w_r (
FloatTensor
) – shape: (*batch_dims, dim) The relation normal vector representations.d_r (
FloatTensor
) – shape: (*batch_dims, dim) The relation difference vector representations.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 \(|x-y|_p^p\).
- Return type:
FloatTensor
- Returns:
shape: batch_dims The scores.