快捷方式

torch.atleast_2d

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

返回每個輸入張量的二維檢視(對於零維張量)。對於二維或更高維度的輸入張量,則按原樣返回。

引數

input (Tensorlist of Tensors) –

返回值

output (Tensor 或 Tensor 元組)

示例

>>> x = torch.tensor(1.)
>>> x
tensor(1.)
>>> torch.atleast_2d(x)
tensor([[1.]])
>>> x = torch.arange(4).view(2, 2)
>>> x
tensor([[0, 1],
        [2, 3]])
>>> torch.atleast_2d(x)
tensor([[0, 1],
        [2, 3]])
>>> x = torch.tensor(0.5)
>>> y = torch.tensor(1.)
>>> torch.atleast_2d((x, y))
(tensor([[0.5000]]), tensor([[1.]]))

© Copyright PyTorch 貢獻者。

使用 Sphinx 構建,主題由 Read the Docs 提供。

文件

查閱 PyTorch 全面的開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並解答您的疑問

檢視資源