safe_cumprod {tfaddons}R Documentation

Safe cumprod

Description

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

Usage

safe_cumprod(x, ...)

Arguments

x

Tensor to take the cumulative product of.

...

Passed on to cumsum; these are identical to those in cumprod

Details

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.

Value

Cumulative product of x.


[Package tfaddons version 0.10.0 Index]