Basic sigmoid, s = 1/(1 + e^{-x}) / s = math.exp(x)

please explain to a math and python dummy. I tried both
s = 1/(1 + e^{-x})
s = math.exp(x)

The point is that math.exp(x) is the way you say e^x in python in the case that x is a scalar value. So e^{-x} would be math.exp(-x), right? Now you need to incorporate that into the formula for sigmoid. That would be:

\sigma(x) = \displaystyle \frac {1}{1 + e^{-x}}

So how would you write that in python?


Also, I would point out that in python the ^ symbol does not mean exponentiation, for that you need to use two asterisks **, and you should use () instead of {} in arithmetic expressions.

For example, to write a^b in python you use a**b.


1/(1+math.exp(-x)) works. You mean 1/(1+math.exp**-x)? It does not pass.

1 Like

My comment was for python in general, not for this particular case. I was only adding information because I saw you tried to use the incorrect symbol for exponentiation


math.exp is the name of a function in python. You call (‘invoke’) a function with an argument. What would it mean to raise a function to a power? You can find the documentation for math.exp by googling “python math exp”.

BTW the operator ^ in python is “exclusive OR”, which is a Boolean operation.