From d2ad8abe4bb8529c5b1ef4b3a956271e7d6d813b Mon Sep 17 00:00:00 2001 From: txh18 Date: Wed, 27 Jan 2016 21:48:13 +0800 Subject: added logp addition to LMResult --- nerv/examples/lmptb/lmptb/lmutil.lua | 13 ++++++++++--- 1 file 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 -- cgit v1.2.3-70-g09d2