torch.square
-
torch.square(input: Tensor, *, out: Tensor | None) → Tensor -
Возвращает новый тензор с квадратами элементов
input.- Параметры:
-
input (Tensor) – входной тензор.
- Именованные аргументы:
-
out (Tensor, optional) – выходной тензор.
Пример:
>>> a = torch.randn(4) >>> a tensor([-2.0755, 1.0226, 0.0831, 0.4806]) >>> torch.square(a) tensor([ 4.3077, 1.0457, 0.0069, 0.2310])
© 2026, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.14/generated/torch.square.html