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

PyTorch torch.sqrt function

PyTorch torch.sqrt function


PyTorch torch reference manual PyTorch torch reference manual

torch.sqrt is a function in PyTorch used to compute the element-wise square root of a tensor.

Function definition

torch.sqrt(input, out=None)


Usage examples

Example

import

torch

x

=

torch.

tensor

(

[

4.0

,

9.0

,

16.0

,

25.0

]

)

y

=

torch.

sqrt

(

x

)

print

(

y

)

The output is:

tensor([2., 3., 4., 5.])


PyTorch torch reference manual PyTorch torch reference manual