forked from stanfordnlp/treelstm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.lua
More file actions
24 lines (20 loc) · 652 Bytes
/
Copy pathrun.lua
File metadata and controls
24 lines (20 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require('.')
-- load vocab
local vocab = treelstm.Vocab('data/sst/vocab-cased.txt')
-- load dataset
local dataset = treelstm.read_serapis_dataset('../sentiment/', vocab)
printf('num data = %d\n', dataset.size)
-- load model and predict dataset
local model = treelstm.TreeLSTMSentiment.load("trained_models/sent-constituency.2class.1l.150d.2.th")
local predictions = model:predict_dataset(dataset)
-- save predictions
file = io.open('../sentiment/predictions.txt', 'w')
local prediction
for i = 1, predictions:size(1) do
for j = 1, 3 do
file:write(predictions[i][j])
file:write(",")
end
file:write("\n")
end
file:close()