-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetParams.lua
54 lines (48 loc) · 1.29 KB
/
getParams.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
46
47
48
49
50
51
52
53
54
getParams = {}
TEMP = {}
function getParamFromFile(filename)
if pcall(function () io.input(filename)
TEMP.param = nil
local t = io.read("*all")
io.input():close()
for line in string.gmatch(t, "[^\n]+") do
if line:len() > 0 then
TEMP.param= line+0.0
end
end
end) then
print(filename.." "..TEMP.param)
return TEMP.param
else
print("ERROR "..filename)
return nil
end
end
function getAttentionFromFile()
local filename = "attention-"..arg[1]
local result = getParamFromFile(filename)
if result ~= nil then
FIXED_ATTENTION = result
end
end
function getLearningRateFromFile()
local filename = "lr-"..arg[1]
local result = getParamFromFile(filename)
if result ~= nil then
params.lr = result
end
end
function getAttentionLearningRateFromFile()
local filename = "lr-att-"..arg[1]
local result = getParamFromFile(filename)
if result ~= nil then
params.lr_att = result
end
end
function getTotalAttentionWeightFromFile()
local filename = "total-att-weight-"..arg[1]
local result = getParamFromFile(filename)
if result ~= nil then
params.TOTAL_ATTENTIONS_WEIGHT = result
end
end