aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortxh18 <[email protected]>2016-01-27 21:48:13 +0800
committertxh18 <[email protected]>2016-01-27 21:48:13 +0800
commitd2ad8abe4bb8529c5b1ef4b3a956271e7d6d813b (patch)
tree8f9356c8919a99e3f715c5b68e91a8f4b3d9121c
parentceda23dff9e9204ad3061bd65a096ae33d94d757 (diff)
added logp addition to LMResult
-rw-r--r--nerv/examples/lmptb/lmptb/lmutil.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/nerv/examples/lmptb/lmptb/lmutil.lua b/nerv/examples/lmptb/lmptb/lmutil.lua
index 6d66d6e..13a5c45 100644
--- a/nerv/examples/lmptb/lmptb/lmutil.lua
+++ b/nerv/examples/lmptb/lmptb/lmutil.lua
@@ -112,10 +112,17 @@ end
--cla:string
--w:string
--prob:float, the probability
-function Result:add(cla, w, prob)
- self[cla].logp_all = self[cla].logp_all + math.log10(prob)
+function Result:add(cla, w, prob, log10ed)
+ local lp
+ if log10ed == true then
+ lp = prob
+ else
+ lp = math.log10(prob)
+ end
+
+ self[cla].logp_all = self[cla].logp_all + lp
if (self.vocab:is_unk_str(w)) then
- self[cla].logp_unk = self[cla].logp_unk + math.log10(prob)
+ self[cla].logp_unk = self[cla].logp_unk + lp
self[cla].cn_unk = self[cla].cn_unk + 1
end
if (w == self.vocab.sen_end_token) then