PyTorch torch.logsumexp function
PyTorch torch reference manual
torch.logsumexp is a function in PyTorch used to compute the log of the sum of exponentials of tensor elements.
Function definition
torch.logsumexp(input, dim, keepdim=False, out=None)
Usage examples
Example
import
torch
Creating tensors
x
=
torch.
tensor
(
[
[
1.0
,
2.0
,
3.0
]
,
[
4.0
,
5.0
,
6.0
]
]
)
Compute logsumexp along a dimension
y
=
torch.
logsumexp
(
x
,
dim
=
1
)
(
"logsumexp:"
,
y
)
The output is:
logsumexp: tensor([ 3.4076, 6.4076])