oneflow.erf

oneflow.erf()

Computes the error function of each element. The error function is defined as follows:

\[\operatorname{erf}(x)=\frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^{2}} d t\]
Parameters

x (oneflow.Tensor) – A Tensor

Returns

The result Tensor

Return type

oneflow.Tensor

For example:

>>> import oneflow as flow
>>> import numpy as np

>>> x = flow.tensor(np.array([0, -1., 10.]), dtype=flow.float32)
>>> out = flow.erf(x)
>>> out.shape
oneflow.Size([3])
>>> out.numpy()
array([ 0.       , -0.8427008,  1.       ], dtype=float32)

>>> x = flow.tensor(np.array([[0, -1., 10.], [5, 7, 0.8]]), dtype=flow.float32)
>>> out = flow.erf(x)
>>> out.shape
oneflow.Size([2, 3])
>>> out.numpy()
array([[ 0.        , -0.8427008 ,  1.        ],
       [ 1.        ,  1.        ,  0.74210095]], dtype=float32)

>>> x = flow.tensor(np.array([[0, -1., 10.], [5, 7, 0.8], [2, 3, 4]]), dtype=flow.float32)
>>> out = x.erf()
>>> out.shape
oneflow.Size([3, 3])
>>> out.numpy()
array([[ 0.        , -0.8427008 ,  1.        ],
       [ 1.        ,  1.        ,  0.74210095],
       [ 0.9953223 ,  0.9999779 ,  1.        ]], dtype=float32)