fn
cumprod
→Tensorcumprod(input: Tensor, dim: DimLike = ...)Return the cumulative product of elements along dim.
Produces a tensor of the same shape as the input whose i-th element
along dim is the product of all input elements up to and including
position i. This is the prefix product and is the multiplicative
analogue of cumsum.
Parameters
inputTensorSource tensor.
dimDimLike= ...Dimension along which to accumulate.
Returns
TensorSame shape as input.
Notes
The reduction is not numerically stable for long sequences of values much greater than 1 (overflow) or much less than 1 (underflow); consider accumulating in log-space when range is large.
Examples
>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0, 4.0])
>>> lucid.cumprod(x, dim=0)
Tensor([ 1., 2., 6., 24.])