KG2ESimilarity

class KG2ESimilarity(exact: bool = True)[source]

Bases: Module, ABC

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:
Returns:

torch.Tensor, shape: (*batch_dims) # noqa: DAR202 The similarity.

Return type:

Tensor