oneflow.logsumexp¶
-
oneflow.
logsumexp
(input, dim, keepdim=False) → Tensor¶ Returns the log of summed exponentials of each row of the
input
tensor in the given dimensiondim
. The computation is numerically stabilized.For summation index \(j\) given by dim and other indices \(i\), the result is
\[\text{logsumexp}(x)_{{i}} = \log \sum_j \exp(x_{{ij}})\]The interface is consistent with PyTorch. The documentation is referenced from: https://pytorch.org/docs/1.12/generated/torch.logsumexp.html.
- Parameters
input (oneflow.Tensor) – the Input Tensor
dim (int or tuple of ints) – the dimension or dimensions to reduce.
keepdim (bool, optional) – whether the output tensor has dim retained or not. Default: False
For example:
>>> import oneflow as flow >>> input = flow.Tensor([[1, 2, 3], [4, 5, 6]]) >>> flow.logsumexp(input, 0) tensor([4.0486, 5.0486, 6.0486], dtype=oneflow.float32) >>> flow.logsumexp(input, 1) tensor([3.4076, 6.4076], dtype=oneflow.float32)