torch.atleast_1d
-
torch.atleast_1d(*tensors)[source] -
Возвращает одномерный вид каждого входного тензора с нулевыми измерениями. Входные тензоры с одним или несколькими измерениями возвращаются как есть.
Пример:
>>> x = torch.arange(2) >>> x tensor([0, 1]) >>> torch.atleast_1d(x) tensor([0, 1]) >>> x = torch.tensor(1.) >>> x tensor(1.) >>> torch.atleast_1d(x) tensor([1.]) >>> x = torch.tensor(0.5) >>> y = torch.tensor(1.) >>> torch.atleast_1d((x, y)) (tensor([0.5000]), tensor([1.]))
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.atleast_1d.html