torch.Tensor.real¶
- Tensor.real¶
傳回一個新的張量,其中包含複數值輸入張量
self
張量的實數值。傳回的張量和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])