tf.group和tf.control_dependencies有什么区别?

Car*_*omé 12 tensorflow

除了tf.control_dependencies作为上下文管理器(即与Python一起使用with)之外,tf.group和之间的区别是tf.control_dependencies什么?

什么时候应该使用?

tf.group没有任何特定的操作顺序吗?我假设tf.group([op_1, op_2, op_3])在列表的顺序中执行ops,但也许情况并非如此?docstring不指定行为.

Yar*_*tov 16

如果你看一下graphdef,c=tf.group(a, b)会产生与图相同的图形

with tf.control_dependencies([a, b]):
    c = tf.no_op() 
Run Code Online (Sandbox Code Playgroud)

运行操作没有特定的顺序,TensorFlow会尽快(即并行)尝试执行操作.