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