KG2EInteraction

class KG2EInteraction(similarity=None, exact=True)[source]

Bases: pykeen.nn.modules.FunctionalInteraction[Tuple[torch.FloatTensor, torch.FloatTensor], Tuple[torch.FloatTensor, torch.FloatTensor], Tuple[torch.FloatTensor, torch.FloatTensor]]

A stateful module for the KG2E interaction function.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

Attributes Summary

entity_shape

The symbolic shapes for entity representations

relation_shape

The symbolic shapes for relation representations

Methods Summary

func(h_var, r_mean, r_var, t_mean, t_var[, …])

Evaluate the KG2E interaction function.

Attributes Documentation

entity_shape: Sequence[str] = ('d', 'd')

The symbolic shapes for entity representations

relation_shape: Sequence[str] = ('d', 'd')

The symbolic shapes for relation representations

Methods Documentation

func(h_var, r_mean, r_var, t_mean, t_var, similarity='KL', exact=True)

Evaluate the KG2E interaction function.

Parameters
  • h_mean (FloatTensor) – shape: (batch_size, num_heads, 1, 1, d) The head entity distribution mean.

  • h_var (FloatTensor) – shape: (batch_size, num_heads, 1, 1, d) The head entity distribution variance.

  • r_mean (FloatTensor) – shape: (batch_size, 1, num_relations, 1, d) The relation distribution mean.

  • r_var (FloatTensor) – shape: (batch_size, 1, num_relations, 1, d) The relation distribution variance.

  • t_mean (FloatTensor) – shape: (batch_size, 1, 1, num_tails, d) The tail entity distribution mean.

  • t_var (FloatTensor) – shape: (batch_size, 1, 1, num_tails, d) The tail entity distribution variance.

  • similarity (str) – The similarity measures for gaussian distributions. From {“KL”, “EL”}.

  • exact (bool) – Whether to leave out constants to accelerate similarity computation.

Return type

FloatTensor

Returns

shape: (batch_size, num_heads, num_relations, num_tails) The scores.