Aside from tf.control_dependencies
being a context manager (i.e. used with Python with
), what's the difference between tf.group
and tf.control_dependencies
?
When should which be used?
Is it that tf.group
doesn't have any particular order of operations? I'd assume tf.group([op_1, op_2, op_3])
executes ops in the list's order, but maybe that's not the case? The docstring doesn't specify a behaviour.
The control dependencies is a system in which whatever operations we create under the "with" block it adds dependencies. Especially what we specify in the argument to "control_dependencies" which is assure to be checked out before anything we define in the "with" block.
tf. group allows you to request that one or more results finish before execution continues. tf.group creates a single op (of type NoOp ), and then adds appropriate control dependencies.
If you look at the graphdef, the c=tf.group(a, b)
produces the same graph as
with tf.control_dependencies([a, b]):
c = tf.no_op()
There's no specific order in which ops will run, TensorFlow tries to execute operations as soon as it can (i.e. in parallel).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With