快捷方式

torch.atleast_3d

torch.atleast_3d(*tensors)[源代码][源代码]

返回每个零维输入 tensor 的三维视图。具有三维或更多维度的输入 tensor 按原样返回。

参数

input (Tensorlist of Tensors) –

返回值

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 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源