Bubblethan
Bubblethan

Reputation: 379

What does tf.no_op() do?

with tf.dependencies([train_step,variable_average_op]):
    train_op = tf.no_op('train')
.....
_, loss, steps = sess.run([train_op, loss, global_step],feed_dict...)

I'm confused what is the function of tf,no_op() here

Upvotes: 4

Views: 3525

Answers (1)

mrry
mrry

Reputation: 126184

As the documentation says, tf.no_op() does nothing. However, when you create a tf.no_op() inside a with tf.control_dependencies([x, y, z]): block, the op will gain control dependencies on ops x, y, and z. Therefore it can be used to group together a set of side effecting ops, and give you a single op to pass to sess.run() in order to run all of them in a single step.

Upvotes: 11

Related Questions