summaryrefslogtreecommitdiff
path: root/layer/affine.lua
diff options
context:
space:
mode:
Diffstat (limited to 'layer/affine.lua')
-rw-r--r--layer/affine.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/layer/affine.lua b/layer/affine.lua
index 94e7497..97703a8 100644
--- a/layer/affine.lua
+++ b/layer/affine.lua
@@ -34,10 +34,10 @@ function nerv.AffineLayer:update(bp_err, input, output)
local gconf = self.gconf
-- momentum gain
local mmt_gain = 1.0 / (1.0 - gconf.momentum);
- local n = input:nrow() * mmt_gain
+ local n = input[0]:nrow() * mmt_gain
-- update corrections (accumulated errors)
- ltc:mul(input, bp_err, 1.0, gconf.momentum, 'T', 'N')
- bc:add(bc, bp_err:colsum(), gconf.momentum, 1.0)
+ ltc:mul(input[0], bp_err[0], 1.0, gconf.momentum, 'T', 'N')
+ bc:add(bc, bp_err[0]:colsum(), gconf.momentum, 1.0)
-- perform update
ltp:add(ltp, ltc, 1.0, -gconf.lrate / n)
bp:add(bp, bc, 1.0, -gconf.lrate / n)
@@ -47,11 +47,11 @@ end
function nerv.AffineLayer:propagate(input, output)
-- apply linear transform
- output:mul(input, self.ltp.trans, 1.0, 0.0, 'N', 'N')
+ output[0]:mul(input[0], self.ltp.trans, 1.0, 0.0, 'N', 'N')
-- add bias
- output:add_row(self.bp.trans, 1.0)
+ output[0]:add_row(self.bp.trans, 1.0)
end
function nerv.AffineLayer:back_propagate(next_bp_err, bp_err, input, output)
- next_bp_err:mul(bp_err, self.ltp.trans, 1.0, 0.0, 'N', 'T')
+ next_bp_err[0]:mul(bp_err[0], self.ltp.trans, 1.0, 0.0, 'N', 'T')
end