|View source on GitHub|
Returns the element-wise sum of a list of tensors.
`tf.accumulate_n`Compat aliases for migration
See Migration guide for more details.
tf.math.accumulate_n( inputs, shape=None, tensor_dtype=None, name=None )
tensor_dtype for shape and type checking, otherwise, these are inferred.
accumulate_n performs the same operation as
tf.math.add_n, but does not wait for all of its inputs to be ready before beginning to sum. This approach can save memory if inputs are ready at different times, since minimum temporary storage is proportional to the output size rather than the inputs' size.
accumulate_n is differentiable (but wasn't previous to TensorFlow 1.7).
a = tf.constant([[1, 2], [3, 4]]) b = tf.constant([[5, 0], [0, 6]]) tf.math.accumulate_n([a, b, a]) # [[7, 4], [6, 14]] # Explicitly pass shape and type tf.math.accumulate_n([a, b, a], shape=[2, 2], tensor_dtype=tf.int32) # [[7, 4], # [6, 14]]
| || A list of |
| || Expected shape of elements of |
| || Expected data type of |
| ||A name for the operation (optional).|
| A |
| || If |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.