tf.math.accumulate_n  |  TensorFlow v2.16.1 (original) (raw)

tf.math.accumulate_n

Stay organized with collections Save and categorize content based on your preferences.

Returns the element-wise sum of a list of tensors. (deprecated)

View aliases

Compat aliases for migration

SeeMigration guide for more details.

tf.compat.v1.accumulate_n, tf.compat.v1.math.accumulate_n

tf.math.accumulate_n(
    inputs, shape=None, tensor_dtype=None, name=None
)

Optionally, pass shape and tensor_dtype for shape and type checking, otherwise, these are inferred.

For example:

a = tf.constant([[1, 2], [3, 4]]) b = tf.constant([[5, 0], [0, 6]]) tf.math.accumulate_n([a, b, a]).numpy() array([[ 7, 4], [ 6, 14]], dtype=int32)

# Explicitly pass shape and type tf.math.accumulate_n( [a, b, a], shape=[2, 2], tensor_dtype=tf.int32).numpy() array([[ 7, 4], [ 6, 14]], dtype=int32)

See Also:

Args
inputs A list of Tensor objects, each with same shape and type.
shape Expected shape of elements of inputs (optional). Also controls the output shape of this op, which may affect type inference in other ops. A value of None means "infer the input shape from the shapes in inputs".
tensor_dtype Expected data type of inputs (optional). A value of Nonemeans "infer the input dtype from inputs[0]".
name A name for the operation (optional).
Returns
A Tensor of same shape and type as the elements of inputs.
Raises
ValueError If inputs don't all have same shape and dtype or the shape cannot be inferred.