From 91075c34160fa24e484148b26c1178e05c2212a4 Mon Sep 17 00:00:00 2001 From: txh18 Date: Thu, 10 Dec 2015 13:28:13 +0800 Subject: bug fix for recent changes in tnn --- nerv/examples/lmptb/lmptb/layer/select_linear.lua | 2 +- nerv/tnn/tnn.lua | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nerv/examples/lmptb/lmptb/layer/select_linear.lua b/nerv/examples/lmptb/lmptb/layer/select_linear.lua index 580b9c5..431ef3a 100644 --- a/nerv/examples/lmptb/lmptb/layer/select_linear.lua +++ b/nerv/examples/lmptb/lmptb/layer/select_linear.lua @@ -30,7 +30,7 @@ function SL:init(batch_size) end function SL:update(bp_err, input, output) - --use this to produce reproducable result + --use this to produce reproducable result, don't forget to set the dropout to zero! --for i = 1, input[1]:nrow(), 1 do -- local word_vec = self.ltp.trans[input[1][i - 1][0]] -- word_vec:add(word_vec, bp_err[1][i - 1], 1, - self.gconf.lrate / self.gconf.batch_size) diff --git a/nerv/tnn/tnn.lua b/nerv/tnn/tnn.lua index bcfeb40..7ae3172 100644 --- a/nerv/tnn/tnn.lua +++ b/nerv/tnn/tnn.lua @@ -466,7 +466,7 @@ function TNN:net_backpropagate(do_update) --propagate according to feeds_now local feeds_now = self.feeds_now for t = 1, self.chunk_size do --some layer maybe do not have outputs from time 1..chunk_size for id, ref in pairs(self.layers) do - self:backpropagate_dfs(ref, t) + self:backpropagate_dfs(ref, t, do_update) end end for t = 1, self.chunk_size do @@ -500,6 +500,9 @@ end --ref: the TNN_ref of a layer --t: the current time to propagate function TNN:backpropagate_dfs(ref, t, do_update) + if do_update == nil then + nerv.error("got a nil do_update") + end if self:out_of_feedrange(t) then return end -- cgit v1.2.3