Sigmoidlogistic function
(0; 1)Details
Squashes any number into the interval $(0,\,1)$, so the output reads as a probability. The curve is S-shaped and symmetric about the point $(0,\,0.5)$; its asymptotes are $y=0$ and $y=1$.
$\sigma(0)=0.5$, $\sigma(2)\approx0.881$, $\sigma(-2)\approx0.119$. The slope peaks at zero: $\sigma'(0)=0.25$, while $\sigma'(2)\approx0.105$.
def sigmoid(x):
return 0.5 * (1 + np.tanh(0.5 * x)) # = 1 / (1 + e^-x), no overflow
def sigmoid_grad(x):
s = sigmoid(x)
return s * (1 - s)