W3cubDocs

/TensorFlow 2.9

tf.group

Create an op that groups multiple operations.

When this op finishes, all ops in inputs have finished. This op has no output.

Note: In TensorFlow 2 with eager and/or Autograph, you should not require this method, as ops execute in the expected order thanks to automatic control dependencies. Only use tf.group when working with v1 tf.Graph code.

When operating in a v1-style graph context, ops are not executed in the same order as specified in the code; TensorFlow will attempt to execute ops in parallel or in an order convenient to the result it is computing. 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. Thus, c = tf.group(a, b) will compute the same graph as this:

with tf.control_dependencies([a, b]):
    c = tf.no_op()

See also tf.tuple and tf.control_dependencies.

Args
*inputs Zero or more tensors to group.
name A name for this operation (optional).
Returns
An Operation that executes all its inputs.
Raises
ValueError If an unknown keyword argument is provided.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/group