Skip to content

Commit

Permalink
generic_trainer always adds l2 values to summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
varisd committed Aug 1, 2018
1 parent f7e6795 commit 5fb7fc9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion neuralmonkey/trainers/generic_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from neuralmonkey.model.model_part import ModelPart
from neuralmonkey.runners.base_runner import (
Executable, ExecutionResult, NextExecute)
from neuralmonkey.trainers.regularizers import Regularizer
from neuralmonkey.trainers.regularizers import (
Regularizer, L2Regularizer)

# pylint: disable=invalid-name
Gradients = List[Tuple[tf.Tensor, tf.Variable]]
Expand Down Expand Up @@ -99,6 +100,9 @@ def __init__(self,
# unweighted losses for fetching
self.losses = [o.loss for o in objectives] + reg_values

# we always want to include l2 values in the summary
if L2Regularizer not in [type(r) for r in self.regularizers]:
reg_values.append(L2Regularizer().value(regularizable))
for reg, reg_value in zip(self.regularizers, reg_values):
tf.summary.scalar(reg.name, reg_value,
collections=["summary_train"])
Expand Down

0 comments on commit 5fb7fc9

Please sign in to comment.