Commit 99f9442b authored by Neal Wu's avatar Neal Wu
Browse files

Remove barrier, add tf.identity where appropriate, and make sure tests pass

parent 8e54ffc8
...@@ -418,7 +418,7 @@ class DropoutTest(tf.test.TestCase): ...@@ -418,7 +418,7 @@ class DropoutTest(tf.test.TestCase):
with self.test_session(): with self.test_session():
images = tf.random_uniform((5, height, width, 3), seed=1) images = tf.random_uniform((5, height, width, 3), seed=1)
output = ops.dropout(images) output = ops.dropout(images)
self.assertEquals(output.op.name, 'Dropout/dropout/mul_1') self.assertEquals(output.op.name, 'Dropout/dropout/mul')
output.get_shape().assert_is_compatible_with(images.get_shape()) output.get_shape().assert_is_compatible_with(images.get_shape())
def testCreateDropoutNoTraining(self): def testCreateDropoutNoTraining(self):
...@@ -599,9 +599,7 @@ class BatchNormTest(tf.test.TestCase): ...@@ -599,9 +599,7 @@ class BatchNormTest(tf.test.TestCase):
output = ops.batch_norm(images, decay=0.1) output = ops.batch_norm(images, decay=0.1)
update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION) update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION)
with tf.control_dependencies(update_ops): with tf.control_dependencies(update_ops):
barrier = tf.no_op(name='gradient_barrier') output = tf.identity(output)
with tf.control_dependencies([barrier]):
output = tf.identity(output)
# Initialize all variables # Initialize all variables
sess.run(tf.global_variables_initializer()) sess.run(tf.global_variables_initializer())
moving_mean = variables.get_variables('BatchNorm/moving_mean')[0] moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
...@@ -630,9 +628,7 @@ class BatchNormTest(tf.test.TestCase): ...@@ -630,9 +628,7 @@ class BatchNormTest(tf.test.TestCase):
output = ops.batch_norm(images, decay=0.1, is_training=False) output = ops.batch_norm(images, decay=0.1, is_training=False)
update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION) update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION)
with tf.control_dependencies(update_ops): with tf.control_dependencies(update_ops):
barrier = tf.no_op(name='gradient_barrier') output = tf.identity(output)
with tf.control_dependencies([barrier]):
output = tf.identity(output)
# Initialize all variables # Initialize all variables
sess.run(tf.global_variables_initializer()) sess.run(tf.global_variables_initializer())
moving_mean = variables.get_variables('BatchNorm/moving_mean')[0] moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
...@@ -665,9 +661,7 @@ class BatchNormTest(tf.test.TestCase): ...@@ -665,9 +661,7 @@ class BatchNormTest(tf.test.TestCase):
output = ops.batch_norm(images, decay=0.1, is_training=False) output = ops.batch_norm(images, decay=0.1, is_training=False)
update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION) update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION)
with tf.control_dependencies(update_ops): with tf.control_dependencies(update_ops):
barrier = tf.no_op(name='gradient_barrier') output = tf.identity(output)
with tf.control_dependencies([barrier]):
output = tf.identity(output)
# Initialize all variables # Initialize all variables
sess.run(tf.global_variables_initializer()) sess.run(tf.global_variables_initializer())
moving_mean = variables.get_variables('BatchNorm/moving_mean')[0] moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
......
...@@ -379,7 +379,7 @@ def deploy(config, ...@@ -379,7 +379,7 @@ def deploy(config,
update_op = tf.group(*update_ops) update_op = tf.group(*update_ops)
with tf.control_dependencies([update_op]): with tf.control_dependencies([update_op]):
train_op = total_loss train_op = tf.identity(total_loss, name='train_op')
else: else:
clones_losses = [] clones_losses = []
regularization_losses = tf.get_collection( regularization_losses = tf.get_collection(
......
...@@ -540,7 +540,7 @@ def main(_): ...@@ -540,7 +540,7 @@ def main(_):
update_op = tf.group(*update_ops) update_op = tf.group(*update_ops)
with tf.control_dependencies([update_op]): with tf.control_dependencies([update_op]):
train_tensor = total_loss train_tensor = tf.identity(total_loss, name='train_op')
# Add the summaries from the first clone. These contain the summaries # Add the summaries from the first clone. These contain the summaries
# created by model_fn and either optimize_clones() or _gather_clone_loss(). # created by model_fn and either optimize_clones() or _gather_clone_loss().
......
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