Skip to content

Commit

Permalink
MDL-67040 Regularization for the loss function
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllaó committed Jan 10, 2020
1 parent 608cac3 commit 91db1e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion moodlemlbackend/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.4.0
5 changes: 5 additions & 0 deletions moodlemlbackend/model/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def build_graph(self, initial_weights=False):

loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(
logits=self.probs, labels=self.y_))

regularizer = (tf.nn.l2_loss(W['input-hidden']) * 0.01) + \
(tf.nn.l2_loss(W['hidden-output']) * 0.01)
loss = tf.reduce_mean(loss + regularizer)

tf.summary.scalar("loss", loss)

with tf.name_scope('accuracy'):
Expand Down

0 comments on commit 91db1e9

Please sign in to comment.