@@ -17,7 +17,6 @@ class NeuralLogicProgramming(nn.Module, core.Configurable):
17
17
https://papers.nips.cc/paper/2017/file/0e55666a4ad822e0e34299df3591d979-Paper.pdf
18
18
19
19
Parameters:
20
- num_entity (int): number of entities
21
20
num_relation (int): number of relations
22
21
hidden_dim (int): dimension of hidden units in LSTM
23
22
num_step (int): number of recurrent steps
@@ -26,17 +25,15 @@ class NeuralLogicProgramming(nn.Module, core.Configurable):
26
25
27
26
eps = 1e-10
28
27
29
- def __init__ (self , num_entity , num_relation , hidden_dim , num_step , num_lstm_layer = 1 ):
28
+ def __init__ (self , num_relation , hidden_dim , num_step , num_lstm_layer = 1 ):
30
29
super (NeuralLogicProgramming , self ).__init__ ()
31
30
32
31
num_relation = int (num_relation )
33
- self .num_entity = num_entity
34
32
self .num_relation = num_relation
35
33
self .num_step = num_step
36
34
37
35
self .query = nn .Embedding (num_relation * 2 + 1 , hidden_dim )
38
36
self .lstm = nn .LSTM (hidden_dim , hidden_dim , num_lstm_layer )
39
- self .key_linear = nn .Linear (hidden_dim , hidden_dim )
40
37
self .weight_linear = nn .Linear (hidden_dim , num_relation * 2 )
41
38
self .linear = nn .Linear (1 , 1 )
42
39
@@ -56,7 +53,7 @@ def get_t_output(self, graph, h_index, r_index):
56
53
query = self .query (q_index )
57
54
58
55
hidden , hx = self .lstm (query )
59
- memory = functional .one_hot (h_index , self .num_entity ).unsqueeze (0 )
56
+ memory = functional .one_hot (h_index , graph .num_entity ).unsqueeze (0 )
60
57
61
58
for i in range (self .num_step ):
62
59
key = hidden [i ]
0 commit comments