summaryrefslogtreecommitdiff
path: root/model/lstm.py
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-01-17 16:35:28 +0100
committerAlex Auvolat <alex@adnab.me>2017-01-17 16:35:28 +0100
commit2a4f89c41b82e7173d6fb4481af0dcd58c812c19 (patch)
treed99f1cf430c86b54449de1ae1fb66dfd00f9c098 /model/lstm.py
parent9524ab7589f1083608cae5608e16285b0707bc48 (diff)
downloadtext-rnn-2a4f89c41b82e7173d6fb4481af0dcd58c812c19.tar.gz
text-rnn-2a4f89c41b82e7173d6fb4481af0dcd58c812c19.zip
Stuff.
Diffstat (limited to 'model/lstm.py')
-rw-r--r--model/lstm.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/model/lstm.py b/model/lstm.py
index 10b090c..b3b847d 100644
--- a/model/lstm.py
+++ b/model/lstm.py
@@ -129,6 +129,9 @@ class Model():
if config.l1_reg > 0:
l1pen = sum(abs(st).mean() for st in hidden[1:])
cost_reg = cost_reg + config.l1_reg * l1pen
+ if config.l1_reg_weight > 0:
+ l1pen_w = sum(abs(w).mean() for w in VariableFilter(roles=[WEIGHT])(cg))
+ cost_reg = cost_reg + config.l1_reg_weight * l1pen_w
cost_reg += 1e-10 # so that it is not the same Theano variable as cost
error_rate_reg += 1e-10