ntn_interaction

ntn_interaction(h, t, w, vh, vt, b, u, activation)[source]

Evaluate the NTN interaction function.

\[f(h,r,t) = u_r^T act(h W_r t + V_r h + V_r' t + b_r)\]
Parameters
  • h (FloatTensor) – shape: (*batch_dims, dim) The head representations.

  • w (FloatTensor) – shape: (*batch_dims, k, dim, dim) The relation specific transformation matrix W_r.

  • vh (FloatTensor) – shape: (*batch_dims, k, dim) The head transformation matrix V_h.

  • vt (FloatTensor) – shape: (*batch_dims, k, dim) The tail transformation matrix V_h.

  • b (FloatTensor) – shape: (*batch_dims, k) The relation specific offset b_r.

  • u (FloatTensor) – shape: (*batch_dims, k) The relation specific final linear transformation b_r.

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

  • activation (Module) – The activation function.

Return type

FloatTensor

Returns

shape: batch_dims The scores.