• 文档 >
  • torch >
  • torch.atleast_3d
快捷键

torch.atleast_3d

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

返回每个输入张量的三维视图,对于零维度的输入张量。具有三个或更多维度的输入张量将按原样返回。

参数:

输入(张量或张量列表) –

返回值:

输出(张量或张量元组)

示例

>>> 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 贡献者。

使用 Sphinx 构建,主题由 Read the Docs 提供。

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源