torch.Tensor.real ¬
- Tensor.real ¬
返回一个新的张量,包含复数值输入张量的实部。返回的张量与
self
共享相同的底层存储。如果
self
是一个实值张量,则返回self
。- 示例::
>>> 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])