PyTorch torch.float_power 函数

约 350 字 更新于 2026-11-18 5iyo.com
PyTorch torch.float_power 函数

PyTorch torch.float_power 函数


torch.float_power 是 PyTorch 中用于逐元素浮点幂运算的函数。

函数定义

torch.float_power(input, exponent, *, out=None)

使用示例

实例

import torch

# 浮点幂运算示例
x = torch.tensor([2.0, 3.0, 4.0])
y = torch.tensor([2.0, 2.0, 2.0])
result = torch.float_power(x, y)
print(result)  # tensor([4., 9., 16.])