# tf.keras.backend.foldr

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/backend/foldr) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/backend.py#L5720-L5734) |

Reduce elems using fn to combine them from right to left.

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.keras.backend.foldr`](https://www.tensorflow.org/api_docs/python/tf/keras/backend/foldr), \`tf.compat.v2.keras.backend.foldr\`

<br />

    tf.keras.backend.foldr(
        fn, elems, initializer=None, name=None
    )

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `fn` | Callable that will be called upon each element in elems and an accumulator, for instance `lambda acc, x: acc + x` |
| `elems` | tensor |
| `initializer` | The first value used (`elems[-1]` in case of None) |
| `name` | A string name for the foldr node in the graph |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Same type and shape as initializer ||

<br />