PyTorch torch.logaddexp 函数

约 339 字 更新于 2026-11-18 5iyo.com

PyTorch torch.logaddexp 函数


torch.logaddexp 是 PyTorch 中用于计算 log(exp(x) + exp(y)) 的函数。

函数定义

torch.logaddexp(input, other)

使用示例

实例

import torch

# 计算 log(exp(x) + exp(y))
x = torch.tensor([1.0, 2.0])
y = torch.tensor([3.0, 4.0])
z = torch.logaddexp(x, y)
print("logaddexp:", z)

输出结果为:

logaddexp: tensor([3.0486, 4.0181])