torch.broadcast_to
-
torch.broadcast_to(input, shape) → Tensor -
Расширяет
inputдо формыshape. Эквивалентно вызовуinput.expand(shape). Подробнее см.expand().- Параметры:
-
- input (Тензор) – входной тензор.
-
shape (list, tuple, or
torch.Size) – новая форма.
Пример:
>>> x = torch.tensor([1, 2, 3]) >>> torch.broadcast_to(x, (3, 3)) tensor([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
© 2026, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.14/generated/torch.broadcast_to.html