PyTorch torch.real 函数

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

PyTorch torch.real 函数


torch.real 是 PyTorch 中用于返回复数张量的实部的函数。

函数定义

torch.real(input)

使用示例

实例

import torch

# 返回复数张量的实部
x = torch.tensor([1+2j, 3+4j, 5+6j])
result = torch.real(x)
print(result)