aboutsummaryrefslogtreecommitdiff
path: root/layer/affine.lua
diff options
context:
space:
mode:
authorcloudygoose <[email protected]>2015-06-05 21:40:45 +0800
committercloudygoose <[email protected]>2015-06-05 21:40:45 +0800
commit5b4cc22736ade93f4d8348513c4a35f6a9f9be04 (patch)
tree255fbddedcdb25b88f4a70268cb6b1ffbaa5afed /layer/affine.lua
parent90f2b7c257c286e6c52432ed43807f332d97cc7e (diff)
parent37af4bed9c3680fdb9db569605f15013e9b6b64d (diff)
...
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'layer/affine.lua')
-rw-r--r--layer/affine.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/layer/affine.lua b/layer/affine.lua
index 59a0e91..2cd7acb 100644
--- a/layer/affine.lua
+++ b/layer/affine.lua
@@ -41,7 +41,7 @@ function AffineLayer:init()
self.bc:fill(0)
end
-function nerv.AffineLayer:update(bp_err, input, output)
+function AffineLayer:update(bp_err, input, output)
local ltp = self.ltp.trans
local bp = self.bp.trans
local ltc = self.ltc
@@ -60,13 +60,17 @@ function nerv.AffineLayer:update(bp_err, input, output)
ltp:add(ltp, ltp, 1.0, -gconf.lrate * gconf.wcost)
end
-function nerv.AffineLayer:propagate(input, output)
+function AffineLayer:propagate(input, output)
-- apply linear transform
output[1]:mul(input[1], self.ltp.trans, 1.0, 0.0, 'N', 'N')
-- add bias
output[1]:add_row(self.bp.trans, 1.0)
end
-function nerv.AffineLayer:back_propagate(next_bp_err, bp_err, input, output)
+function AffineLayer:back_propagate(next_bp_err, bp_err, input, output)
next_bp_err[1]:mul(bp_err[1], self.ltp.trans, 1.0, 0.0, 'N', 'T')
end
+
+function AffineLayer:get_params()
+ return {self.ltp, self.bp}
+end