summaryrefslogtreecommitdiff
path: root/model/lstm.py
diff options
context:
space:
mode:
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