-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.lua
More file actions
85 lines (65 loc) · 2.18 KB
/
Copy pathinit.lua
File metadata and controls
85 lines (65 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--------------------------------------------------------------------------------
--
-- Graph-Based Recursive Neural Network for Vertex Classification
-- Copyright (C) 2016-2017 Qiongkai Xu, Chenchen Xu
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
--------------------------------------------------------------------------------
require('torch')
require('nn')
require('nngraph')
require('optim')
require('xlua')
require('sys')
require('lfs')
classifier = {}
cora = {}
yelp = {}
util = {}
eval = {}
include('util/util.lua')
include('util/evaluation.lua')
include('util/tree.lua')
include('model/CRowAddTable.lua')
include('model/TreeLSTM.lua')
include('model/ChildSumTreeLSTM.lua')
include('model/ChildSumTreeRNN.lua')
include('model/AttentionChildSumTreeLSTM.lua')
include('main/LogisticModel.lua')
include('main/IterLogisticModel.lua')
include('main/LabelPropogationModel.lua')
include('main/GraphRNN.lua')
printf = utils.printf
-- share module parameters
function share_params(cell, src)
if torch.type(cell) == 'nn.gModule' then
for i = 1, #cell.forwardnodes do
local node = cell.forwardnodes[i]
if node.data.module then
node.data.module:share(src.forwardnodes[i].data.module,
'weight', 'bias', 'gradWeight', 'gradBias')
end
end
elseif torch.isTypeOf(cell, 'nn.Module') then
cell:share(src, 'weight', 'bias', 'gradWeight', 'gradBias')
else
error('parameters cannot be shared for this input')
end
end
function header(s)
print(string.rep('-', 80))
print(s)
print(string.rep('-', 80))
end