The definition of the sigmoid function is
In Python code, it would be sth. like below shows.
import math
def sigmoid(x):
return 1 / (1 + math.exp(-x))
Because it involves a division and a exponent operation, it will cost a certain amount of computing time during the training and prediction process of a neural network. However, since we often use the output of the sigmoid function in a comparison of a given threshold T like
if sigmoid(x) > T:
... do something
we can rewrite the sigmoid formula like below.
Now we get the inverse function of .
Therefore, in terms of the if
statement above, we can take the inverse on the two sides of >
. The left side would be x
, and the right side would be a desigmoid threshold which is a constant as well. So, in the end, the above if
statement can be rewrited to
if x > desigmoid_T:
... do something
This will significantly increase the performance of the if
statement.