From 2a4f89c41b82e7173d6fb4481af0dcd58c812c19 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 17 Jan 2017 16:35:28 +0100 Subject: Stuff. --- model/lstm.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'model/lstm.py') 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 -- cgit v1.2.3