Skip to contents

Logcumsumexp

Usage

torch_logcumsumexp(self, dim)

Arguments

self

(Tensor) the input tensor.

dim

(int) the dimension to do the operation over

logcumsumexp(input, dim, *, out=None) -> Tensor

Returns the logarithm of the cumulative summation of the exponentiation of elements of input in the dimension dim.

For summation index \(j\) given by dim and other indices \(i\), the result is

$$ \mbox{logcumsumexp}(x)_{ij} = \log \sum\limits_{j=0}^{i} \exp(x_{ij}) $$

Examples

if (torch_is_installed()) {

a <- torch_randn(c(10))
torch_logcumsumexp(a, dim=1)
}
#> torch_tensor
#> -0.5970
#>  0.5965
#>  1.7544
#>  1.9720
#>  2.2230
#>  2.2560
#>  2.6027
#>  2.7966
#>  2.8570
#>  2.8857
#> [ CPUFloatType{10} ]