# tf.math.accumulate_n

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/accumulate_n) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/math_ops.py#L3056-L3124) |

Returns the element-wise sum of a list of tensors.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.accumulate_n`](https://www.tensorflow.org/api_docs/python/tf/math/accumulate_n), [`tf.compat.v1.math.accumulate_n`](https://www.tensorflow.org/api_docs/python/tf/math/accumulate_n)

<br />

    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.

`accumulate_n` performs the same operation as [`tf.math.add_n`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/math/add_n).

#### For example:

    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]]

<br />

<br />

<br />

| ## 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 `None` means "infer the input dtype from `inputs[0]`". |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` of same shape and type as the elements of `inputs`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `inputs` don't all have same shape and dtype or the shape cannot be inferred. |

<br />