KG2ESimilarity
- class KG2ESimilarity(exact: bool = True)[source]
-
The similarity between the difference of head and tail distribution and the relation distribution.
Only implemented for multi-variate Gaussian distributions with diagonal covariance matrix.
Initialize the similarity module.
- Parameters:
exact (bool) – Whether to return the exact similarity, or leave out constant offsets for slightly improved speed.
Methods Summary
forward
(h, r, t)Calculate the similarity.
Methods Documentation
- abstract forward(h: GaussianDistribution, r: GaussianDistribution, t: GaussianDistribution) Tensor [source]
Calculate the similarity.
# noqa: DAR401
- Parameters:
h (GaussianDistribution) – shape: (*batch_dims, d) The head entity Gaussian distribution.
r (GaussianDistribution) – shape: (*batch_dims, d) The relation Gaussian distribution.
t (GaussianDistribution) – shape: (*batch_dims, d) The tail entity Gaussian distribution.
- Returns:
torch.Tensor, shape: (*batch_dims) # noqa: DAR202 The similarity.
- Return type: