mindspore.ops.Sqrt

class mindspore.ops.Sqrt[source]

Returns square root of a tensor element-wise.

Note

When there are some negative number, it will return a Tensor whose specific position is nan.

\[out_{i} = \sqrt{x_{i}}\]
Inputs:
  • x (Tensor) - The input tensor.

Outputs:

Tensor, has the same shape and data type as the x.

Raises

TypeError – If x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([1.0, 4.0, 9.0]), mindspore.float32)
>>> sqrt = ops.Sqrt()
>>> output = sqrt(x)
>>> print(output)
[1. 2. 3.]