Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.square function

PyTorch torch.square function


PyTorch torch reference manual 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

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual