diff options
author | Qi Liu <liuq901@163.com> | 2016-05-09 21:02:57 +0800 |
---|---|---|
committer | Qi Liu <liuq901@163.com> | 2016-05-09 21:02:57 +0800 |
commit | 4585970021f75d4c9e7154fc1681a80efa0f48ab (patch) | |
tree | b2773916f1eb836ac3ea0ace5080b881ad2960ba /nerv/layer | |
parent | 03439902dbd339cfbbc684b6fcc6b1810fa02ede (diff) |
clip on gradient now
Diffstat (limited to 'nerv/layer')
-rw-r--r-- | nerv/layer/affine.lua | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/nerv/layer/affine.lua b/nerv/layer/affine.lua index 1ac4681..b68cf3d 100644 --- a/nerv/layer/affine.lua +++ b/nerv/layer/affine.lua @@ -48,6 +48,10 @@ function MatrixParam:_update(alpha, beta) -- momentum gain local mmt_gain = 1.0 / (1.0 - gconf.momentum) local n = gconf.batch_size * mmt_gain + -- clip gradient + if gconf.clip then + self.correction_acc:clip(-gconf.clip, gconf.clip) + end -- perform update if gconf.momentum > 0 then self.correction:add(self.correction, self.correction_acc, gconf.momentum, 1.0) |