捷徑

torch.real

torch.real(input) Tensor

傳回一個新的張量,其中包含 self 張量的實數值。傳回的張量和 self 共享相同的底層儲存空間。

參數

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.real
tensor([ 0.3100, -0.5445, -1.6492, -0.0638])

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得針對初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得問題解答

檢視資源