mindspore.Tensor.erf

Tensor.erf() Tensor

Computes the Gauss error function of input element-wise.

\[erf(x)=\frac{2} {\sqrt{\pi}} \int\limits_0^{x} e^{-t^{2}} dt\]
Parameters

input (Tensor) –

The input tensor of Gaussian error function. \(x\) in the following formula. Supported dtypes:

  • GPU/CPU: float16, float32, float64.

  • Ascend: float16, float32, float64, int64, bool.

Returns

Tensor, has the same shape as the input. The dtype of output is float32 when dtype of input is in [bool, int64]. Otherwise output has the same dtype as the input.

Raises
  • TypeError – If input is not a Tensor.

  • TypeError

    • GPU/CPU: If dtype of input is not float16, float32, float64.

    • Ascend: If dtype of input is not float16, float32, float64, int64, bool.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> input = Tensor(np.array([-1, 0, 1, 2, 3]), mindspore.float32)
>>> output = Tensor.erf(input)
>>> print(output)
[-0.8427168   0.          0.8427168   0.99530876  0.99997765]