summaryrefslogtreecommitdiff
path: root/layer
diff options
context:
space:
mode:
Diffstat (limited to 'layer')
-rw-r--r--layer/affine.lua12
-rw-r--r--layer/sigmoid.lua4
2 files changed, 8 insertions, 8 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
diff --git a/layer/sigmoid.lua b/layer/sigmoid.lua
index d0a87c0..41a6ef7 100644
--- a/layer/sigmoid.lua
+++ b/layer/sigmoid.lua
@@ -10,9 +10,9 @@ function SigmoidLayer:update(bp_err, input, output)
end
function SigmoidLayer:propagate(input, output)
- output:sigmoid(input)
+ output[0]:sigmoid(input[0])
end
function SigmoidLayer:back_propagate(next_bp_err, bp_err, input, output)
- next_bp_err:sigmoid_grad(bp_err, output)
+ next_bp_err[0]:sigmoid_grad(bp_err[0], output[0])
end