PyTorch torch.logsumexp Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.logsumexpIt is a function in PyTorch used to compute the log-sum-exp of tensor elements.

Function Definition

torch.logsumexp(input, dim, keepdim=False, out=None)

Usage Example

Example

import torch

# Create tensor
x = torch.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])

# Compute logsumexp by dimension
y = torch.logsumexp(x, dim=1)
print("logsumexp:", y)

The output result is:

logsumexp: tensor([ 3.4076, 6.4076])

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions