diff options
author | Determinant <[email protected]> | 2015-06-05 17:53:05 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-06-05 17:53:05 +0800 |
commit | 37af4bed9c3680fdb9db569605f15013e9b6b64d (patch) | |
tree | 5f870d23f241edbc670c2778c955f6bd9d5eb1d5 /layer/affine.lua | |
parent | eba6049a82455499c68ee875843b6f44d6164fa5 (diff) |
add get_params to all layers
Diffstat (limited to 'layer/affine.lua')
-rw-r--r-- | layer/affine.lua | 10 |
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 |