ProjEInteraction

class ProjEInteraction(embedding_dim=50, inner_non_linearity=None)[source]

Bases: FunctionalInteraction[FloatTensor, FloatTensor, FloatTensor]

A stateful module for the ProjE interaction function.

Initialize the interaction module.

Parameters
  • embedding_dim (int) – the embedding dimension of entities and relations

  • inner_non_linearity (Union[str, Module, Type[Module], None]) – the inner non-linearity, or a hint thereof. Defaults to nn.Tanh. Disable by passing nn.Idenity

Methods Summary

func(r, t, d_e, d_r, b_c, b_p, activation)

Evaluate the ProjE interaction function.

reset_parameters()

Reset parameters the interaction function may have.

Methods Documentation

func(r, t, d_e, d_r, b_c, b_p, activation)

Evaluate the ProjE interaction function.

\[f(h, r, t) = g(t z(D_e h + D_r r + b_c) + b_p)\]
Parameters
  • h (FloatTensor) – shape: (*batch_dims, dim) The head representations.

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

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

  • d_e (FloatTensor) – shape: (dim,) Global entity projection.

  • d_r (FloatTensor) – shape: (dim,) Global relation projection.

  • b_c (FloatTensor) – shape: (dim,) Global combination bias.

  • b_p (FloatTensor) – shape: scalar Final score bias

  • activation (Module) – The activation function.

Return type

FloatTensor

Returns

shape: batch_dims The scores.

reset_parameters()[source]

Reset parameters the interaction function may have.