torch.functional.atleast_2d#
- torch.functional.atleast_2d(*tensors)[source]#
為零維的每個輸入張量返回一個二維檢視。維度大於或等於二維的輸入張量將按原樣返回。
- 引數
input (Tensor 或 Tensor 序列) – 要轉換為至少二維的張量。
- 返回
output (Tensor or tuple of Tensors)
示例
>>> 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.]])) >>> torch.atleast_2d() ()