Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between tf.group and tf.control_dependencies?

Tags:

tensorflow

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.

like image 771
Carl Thomé Avatar asked Jan 21 '17 14:01

Carl Thomé


People also ask

What is TF Control_dependencies?

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.

What is a TF group?

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.


1 Answers

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).

like image 172
Yaroslav Bulatov Avatar answered Oct 04 '22 15:10

Yaroslav Bulatov