Commit 83c3a098 authored by Yuxin Wu's avatar Yuxin Wu

name scope clean-ups in regularization and resnet (#340)

parent 979d18ca
...@@ -157,6 +157,7 @@ def eval_on_ILSVRC12(model, model_file, dataflow): ...@@ -157,6 +157,7 @@ def eval_on_ILSVRC12(model, model_file, dataflow):
def image_preprocess(image, bgr=True): def image_preprocess(image, bgr=True):
with tf.name_scope('image_preprocess'):
if image.dtype.base_dtype != tf.float32: if image.dtype.base_dtype != tf.float32:
image = tf.cast(image, tf.float32) image = tf.cast(image, tf.float32)
image = image * (1.0 / 255) image = image * (1.0 / 255)
...@@ -177,8 +178,9 @@ def compute_loss_and_error(logits, label): ...@@ -177,8 +178,9 @@ def compute_loss_and_error(logits, label):
loss = tf.reduce_mean(loss, name='xentropy-loss') loss = tf.reduce_mean(loss, name='xentropy-loss')
def prediction_incorrect(logits, label, topk=1, name='incorrect_vector'): def prediction_incorrect(logits, label, topk=1, name='incorrect_vector'):
return tf.cast(tf.logical_not(tf.nn.in_top_k(logits, label, topk)), with tf.name_scope('prediction_incorrect'):
tf.float32, name=name) x = tf.logical_not(tf.nn.in_top_k(logits, label, topk))
return tf.cast(x, tf.float32, name=name)
wrong = prediction_incorrect(logits, label, 1, name='wrong-top1') wrong = prediction_incorrect(logits, label, 1, name='wrong-top1')
add_moving_summary(tf.reduce_mean(wrong, name='train-error-top1')) add_moving_summary(tf.reduce_mean(wrong, name='train-error-top1'))
......
...@@ -46,6 +46,7 @@ def regularize_cost(regex, func, name='regularize_cost'): ...@@ -46,6 +46,7 @@ def regularize_cost(regex, func, name='regularize_cost'):
# If vars are replicated, only regularize those in the current tower # If vars are replicated, only regularize those in the current tower
params = ctx.filter_vars_by_vs_name(params) params = ctx.filter_vars_by_vs_name(params)
with tf.name_scope('regularize_cost'):
costs = [] costs = []
for p in params: for p in params:
para_name = p.name para_name = p.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment