评价此页

torch.real#

torch.real(input) Tensor#

返回一个包含 `self` 张量实数值的新张量。返回的张量与 `self` 共享相同的底层存储。

参数

input (Tensor) – 输入张量。

示例

>>> x=torch.randn(4, dtype=torch.cfloat)
>>> x
tensor([(0.3100+0.3553j), (-0.5445-0.7896j), (-1.6492-0.0633j), (-0.0638-0.8119j)])
>>> x.real
tensor([ 0.3100, -0.5445, -1.6492, -0.0638])