aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortxh18 <cloudygooseg@gmail.com>2015-11-17 23:32:37 +0800
committertxh18 <cloudygooseg@gmail.com>2015-11-17 23:32:37 +0800
commit2ded0597dc3b6a09b47dbe65911573b645d64e36 (patch)
tree2ce8429ed0c54bd20a4a9af892b808099674c63e
parent54226ba490b65c223a230dc5de5cea56b1543594 (diff)
switch to kernel update
-rw-r--r--nerv/examples/lmptb/lmptb/layer/select_linear.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/nerv/examples/lmptb/lmptb/layer/select_linear.lua b/nerv/examples/lmptb/lmptb/layer/select_linear.lua
index b215d48..e96296f 100644
--- a/nerv/examples/lmptb/lmptb/layer/select_linear.lua
+++ b/nerv/examples/lmptb/lmptb/layer/select_linear.lua
@@ -30,12 +30,14 @@ function SL:init(batch_size)
end
function SL:update(bp_err, input, output)
- 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)
- end
+ --use this to produce reproducable result
+ --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)
+ --end
+
--I tried the update_select_rows kernel which uses atomicAdd, but it generates unreproducable result
- --self.ltp.trans:update_select_rows(bp_err[1], input[1]:trans(), - self.gconf.lrate / self.gconf.batch_size, 0)
+ self.ltp.trans:update_select_rows(bp_err[1], input[1]:trans(), - self.gconf.lrate / self.gconf.batch_size, 0)
self.ltp.trans:add(self.ltp.trans, self.ltp.trans, 1.0, - self.gconf.lrate * self.gconf.wcost / self.gconf.batch_size)
end