NTNInteraction¶
-
class
NTNInteraction
(non_linearity=None)[source]¶ Bases:
pykeen.nn.modules.FunctionalInteraction
[torch.FloatTensor
,Tuple
[torch.FloatTensor
,torch.FloatTensor
,torch.FloatTensor
,torch.FloatTensor
,torch.FloatTensor
],torch.FloatTensor
]A stateful module for the NTN interaction function.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
Attributes Summary
The symbolic shapes for relation representations
Methods Summary
func
(t, w, vh, vt, b, u, activation)Evaluate the NTN interaction function.
Attributes Documentation
-
relation_shape
: Sequence[str] = ('kdd', 'kd', 'kd', 'k', 'k')¶ The symbolic shapes for relation representations
Methods Documentation
-
func
(t, w, vh, vt, b, u, activation)¶ 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.
-