Skip to content

Commit

Permalink
Add a tf.summary.scalar call for L2 loss in resnet
Browse files Browse the repository at this point in the history
  • Loading branch information
nealwu committed Mar 22, 2018
1 parent 4b85dab commit d821ab8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion official/resnet/resnet_run_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ def exclude_batch_norm(name):
loss_filter_fn = loss_filter_fn or exclude_batch_norm

# Add weight decay to the loss.
loss = cross_entropy + weight_decay * tf.add_n(
l2_loss = weight_decay * tf.add_n(
[tf.nn.l2_loss(v) for v in tf.trainable_variables()
if loss_filter_fn(v.name)])
tf.summary.scalar('l2_loss', l2_loss)
loss = cross_entropy + l2_loss

if mode == tf.estimator.ModeKeys.TRAIN:
global_step = tf.train.get_or_create_global_step()
Expand Down

0 comments on commit d821ab8

Please sign in to comment.