erf() in Pytorch torch.erf(tensor, out=None) Computes the error function of each element. The error function is defined as follows:
e
r
f
(
x
)
=
2
π
∫
0
x
e
−
t
2
d
t
erf(x)=\frac{2}{\pi}\int_0^xe^{-t^2}dt
erf(x)=π2∫0xe−t2dt
What is error function? Error function (also called the Gauss error function) is a special function (non-elementary) of sigmoid shape that occurs in probility, statistics, and partial differential equations describing diffusion.
Look at the picture:
import numpy as np
from scipy import integrate
import matplotlib.pyplot as plt
x = np.linspace(-5,5,100)
erf = []
sigmoid = []
for x_ in x:
erf.append( integrate.quad(lambda t:np.exp(-t**2),-x_,x_) / np.sqrt(np.pi))
plt.plot(erf)
plt.grid(True)
plt.show()