in scipy.special.expit
, logistic function is implemented like the following:
if x < 0
a = exp(x)
a / (1 + a)
else
1 / (1 + exp(-x))
However, I have seen implementations in other languages/frameworks that simply do
1 / (1 + exp(-x))
I am wondering how much benefit the scipy version actually brings.
For very small x
, the result approaches to 0. It works even if exp(-x)
overflows to Inf
.