# Week 2 assignment error 2

I think my code is correct, but got error. Anyone has encountered the same? how did you resolved it? Thanks.

{moderator edit - solution code removed}

print("basic_sigmoid(1) = " + str(basic_sigmoid(1)))

basic_sigmoid_test(basic_sigmoid)

## basic_sigmoid(1) = 2.718281828459045 Error: Wrong output. 1 Tests passed 1 Tests failed

AssertionError Traceback (most recent call last)
in
1 print("basic_sigmoid(1) = " + str(basic_sigmoid(1)))
2
----> 3 basic_sigmoid_test(basic_sigmoid)

~/work/release/W2A1/public_tests.py in basic_sigmoid_test(target)
21 ]
22
—> 23 test(test_cases, target)
24
25 ### ex 3

~/work/release/W2A1/test_utils.py in test(test_cases, target)
24 print(‘\033[92m’, success," Tests passed")
25 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
—> 26 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for basic_sigmoid. Check your equations and avoid using global variables inside the function.

No, your code is clearly not right. The output of `sigmoid` should be a number between 0 and 1, right? But your answer for `sigmoid(1) = 2.71828...`

We can see from your code that you have implemented

sigmoid(x) = e^x

But if you look at the formula for sigmoid, it’s a bit more complicated than that. When they said to “use math.exp” they did not mean that was the complete answer.

`math.exp(x)` is just the python equivalent of e^x. You need that as part of the formula, but that is not the whole story.

2 Likes