Skip to content

Commit f478547

Browse files
authored
Merge pull request #3694 from tensorflow/resnet-l2-loss
Add a tf.summary.scalar call for L2 loss in resnet
2 parents 6daba3b + d821ab8 commit f478547

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

official/resnet/resnet_run_loop.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ def exclude_batch_norm(name):
235235
loss_filter_fn = loss_filter_fn or exclude_batch_norm
236236

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

242244
if mode == tf.estimator.ModeKeys.TRAIN:
243245
global_step = tf.train.get_or_create_global_step()

0 commit comments

Comments
 (0)