快捷方式

torch.atleast_3d

torch.atleast_3d(*tensors)[原始碼][原始碼]

傳回每個具有零維度的輸入張量的 3 維檢視。具有三個或更多維度的輸入張量會按原樣傳回。

參數

input (TensorTensor 列表) –

傳回

output (Tensor 或 Tensor 元組)

範例

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

        [[2],
         [3]]])
>>> x = torch.tensor(1).view(1, 1, 1)
>>> x
tensor([[[1]]])
>>> torch.atleast_3d(x)
tensor([[[1]]])
>>> x = torch.tensor(0.5)
>>> y = torch.tensor(1.0)
>>> torch.atleast_3d((x, y))
(tensor([[[0.5000]]]), tensor([[[1.]]]))

文件

取得 PyTorch 的完整開發者文件

檢視文件

教學

取得為初學者和進階開發者提供的深入教學

檢視教學

資源

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

檢視資源