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_size, num_heads, 1, 1, dim) The head representations.w (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, k, dim, dim) The relation specific transformation matrix W_r.vh (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, k, dim) The head transformation matrix V_h.vt (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, k, dim) The tail transformation matrix V_h.b (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, k) The relation specific offset b_r.u (
FloatTensor
) – shape: (batch_size, 1, num_relations, 1, k) The relation specific final linear transformation b_r.t (
FloatTensor
) – shape: (batch_size, 1, 1, num_tails, dim) The tail representations.activation (
Module
) – The activation function.
- Return type
FloatTensor
- Returns
shape: (batch_size, num_heads, num_relations, num_tails) The scores.