CPInteraction¶
- class CPInteraction(*args, **kwargs)[source]¶
Bases:
FunctionalInteraction
[FloatTensor
,FloatTensor
,FloatTensor
]An implementation of the CP interaction as described [lacroix2018] (originally from [hitchcock1927]).
Note
For \(k=1\), this interaction is the same as DistMult (but consider the note below).
Note
For equivalence to CP, entities should have different representations for head & tail role. This is different to DistMult.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
Attributes Summary
The symbolic shapes for entity representations
The symbolic shapes for relation representations
Methods Summary
func
(r, t)Evaluate the Canonical Tensor Decomposition interaction function.
Attributes Documentation
Methods Documentation
- func(r, t)¶
Evaluate the Canonical Tensor Decomposition interaction function.
- Parameters:
h (
FloatTensor
) – shape: (*batch_dims, rank, dim) The head representations.r (
FloatTensor
) – shape: (*batch_dims, rank, dim) The relation representations.t (
FloatTensor
) – shape: (*batch_dims, rank, dim) The tail representations.
- Return type:
FloatTensor
- Returns:
shape: batch_dims The scores.