評價此頁

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])