PyTorch torch.square function
PyTorch torch reference manual
torch.square is a function in PyTorch used to compute the element-wise square.
Function definition
torch.square(input, out=None)
Usage examples
Example
import
torch
Compute the element-wise square
x
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
]
)
result
=
torch.
square
(
x
)
(
result
)