# tf.contrib.seq2seq.safe_cumprod

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py#L1177-L1198) |

Computes cumprod of x in logspace using cumsum to avoid underflow.

    tf.contrib.seq2seq.safe_cumprod(
        x, *args, **kwargs
    )

The cumprod function and its gradient can result in numerical instabilities
when its argument has very small and/or zero values. As long as the argument
is all positive, we can instead compute the cumulative product as
exp(cumsum(log(x))). This function can be called identically to tf.cumprod.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Tensor to take the cumulative product of. |
| `*args` | Passed on to cumsum; these are identical to those in cumprod. |
| `**kwargs` | Passed on to cumsum; these are identical to those in cumprod. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Cumulative product of x. ||

<br />