PyTorch torch.logaddexp2 函数

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

PyTorch torch.logaddexp2 函数


torch.logaddexp2 是 PyTorch 中用于计算 log2(2^x + 2^y) 的函数。

函数定义

torch.logaddexp2(input, other)

使用示例

实例

import torch

# 计算 log2(2^x + 2^y)
x = torch.tensor([1.0, 2.0])
y = torch.tensor([3.0, 4.0])
z = torch.logaddexp2(x, y)
print("logaddexp2:", z)

输出结果为:

logaddexp2: tensor([3.0875, 4.0236])