Week 2 exercise 2 Doubt

When I code s = math.exp(x), I’m getting the above error. What’s the mistake?

A number of things. First, take note the “signature” of the sigmoid function defines the defines z, not x, as its (only) argument. So your expression for s = ... should have z on the right-hand side. Even with that, your Python expression is wrong. Read carefully the instructions to Exercise 3, which clearly displays the formula for the sigmoid function. Finally, although you can use the math module from the Python standard library in this exercise, better now to become familiar with the NumPy library (which is imported in the very first command of the notebook).

Right! They tell you to “use math.exp”, but that is not the complete answer. The formula as you implemented it is this:

s = e^x

The point is that the formula for sigmoid does involve e^x, but it is a bit more complicated than that. :nerd_face:

Thank you! I was just implementing the exponential formula but not the sigmoid.