TransDInteraction

class TransDInteraction(p=2, power_norm=True)[source]

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

A stateful module for the TransD interaction function.

Initialize the norm-based interaction function.

Parameters
  • p (int) – The norm used with torch.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

entity_shape

The symbolic shapes for entity representations

relation_shape

The symbolic shapes for relation representations

Methods Summary

func(r, t, h_p, r_p, t_p, p[, power_norm])

Evaluate the TransD interaction function.

Attributes Documentation

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

The symbolic shapes for entity representations

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

The symbolic shapes for relation representations

Methods Documentation

func(r, t, h_p, r_p, t_p, p, power_norm=False)

Evaluate the TransD interaction function.

Parameters
  • h (FloatTensor) – shape: (*batch_dims, d_e) The head representations.

  • r (FloatTensor) – shape: (*batch_dims, d_r) The relation representations.

  • t (FloatTensor) – shape: (*batch_dims, d_e) The tail representations.

  • h_p (FloatTensor) – shape: (*batch_dims, d_e) The head projections.

  • r_p (FloatTensor) – shape: (*batch_dims, d_r) The relation projections.

  • t_p (FloatTensor) – shape: (*batch_dims, d_e) The tail projections.

  • p (int) – The parameter p for selecting the norm.

  • power_norm (bool) – Whether to return the powered norm instead.

Return type

FloatTensor

Returns

shape: batch_dims The scores.