ERMLPInteraction

class ERMLPInteraction(embedding_dim, hidden_dim)[source]

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

A stateful module for the ER-MLP interaction.

\[f(h, r, t) = W_2 ReLU(W_1 cat(h, r, t) + b_1) + b_2\]

Initialize the interaction function.

Parameters
  • embedding_dim (int) – The embedding vector dimension.

  • hidden_dim (int) – The hidden dimension of the MLP.

Methods Summary

func(r, t, hidden, activation, final)

Evaluate the ER-MLP interaction function.

reset_parameters()

Reset parameters the interaction function may have.

Methods Documentation

func(r, t, hidden, activation, final)

Evaluate the ER-MLP interaction function.

Parameters
  • h (FloatTensor) – shape: (batch_size, num_heads, 1, 1, dim) The head representations.

  • r (FloatTensor) – shape: (batch_size, 1, num_relations, 1, dim) The relation representations.

  • t (FloatTensor) – shape: (batch_size, 1, 1, num_tails, dim) The tail representations.

  • hidden (Linear) – The first linear layer.

  • activation (Module) – The activation function of the hidden layer.

  • final (Linear) – The second linear layer.

Return type

FloatTensor

Returns

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

reset_parameters()[source]

Reset parameters the interaction function may have.