torch.Tensor.imag¶
- Tensor.imag¶
返回一個新的 tensor,其中包含
self
tensor 的虛數值。返回的 tensor 和self
共享相同的底層儲存空間。警告
imag()
僅支援具有複數 dtype 的 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.imag tensor([ 0.3553, -0.7896, -0.0633, -0.8119])