快捷方式

torch.atleast_1d

torch.atleast_1d(*tensors)[source][source]

返回每個零維輸入張量的一維檢視。具有一維或更多維度的輸入張量原樣返回。

引數

input (張量張量列表) –

返回

輸出 (張量 或 張量元組)

示例

>>> x = torch.arange(2)
>>> x
tensor([0, 1])
>>> torch.atleast_1d(x)
tensor([0, 1])
>>> x = torch.tensor(1.)
>>> x
tensor(1.)
>>> torch.atleast_1d(x)
tensor([1.])
>>> x = torch.tensor(0.5)
>>> y = torch.tensor(1.)
>>> torch.atleast_1d((x, y))
(tensor([0.5000]), tensor([1.]))

文件

查閱 PyTorch 全面的開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源