forked from stanfordnlp/treelstm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
45 lines (39 loc) · 1.06 KB
/
init.lua
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
require('torch')
require('nn')
require('nngraph')
require('optim')
require('xlua')
require('sys')
require('lfs')
treelstm = {}
include('util/read_data.lua')
include('util/Tree.lua')
include('util/Vocab.lua')
include('layers/CRowAddTable.lua')
include('models/LSTM.lua')
include('models/TreeLSTM.lua')
include('models/ChildSumTreeLSTM.lua')
include('models/BinaryTreeLSTM.lua')
include('relatedness/LSTMSim.lua')
include('relatedness/TreeLSTMSim.lua')
include('sentiment/LSTMSentiment.lua')
include('sentiment/TreeLSTMSentiment.lua')
printf = utils.printf
-- global paths (modify if desired)
treelstm.data_dir = 'data'
treelstm.models_dir = 'trained_models'
treelstm.predictions_dir = 'predictions'
-- share parameters of nngraph gModule instances
function share_params(cell, src, ...)
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, ...)
end
end
end
function header(s)
print(string.rep('-', 80))
print(s)
print(string.rep('-', 80))
end