That can’t possibly be the code you are actually running. Note that the output of sigmoid should be between 0 and 1, right?
I’d say your code looks correct, but notice that your answer for basic_sigmoid(1) is e, right? So what I bet happened is that you typed the new code, but did not click “Shift - Enter” on the basic_sigmoid cell. Unless you do that, just typing the new code does nothing. If you simply call the function again, you are running the old code, which probably was this:
Don’t feel bad about that: the purpose of this first assignment is to get used to how the notebooks work as well as to get introduced to numpy. So keep that in mind as you go through the rest of the course. It’s easy to see the effect I described once you know about it: you can do a little experiment to prove to yourself how it works. Change the code by adding a factor of 2 and then run the test again without clicking “Shift-Enter” and nothing changes, right? Now click “Shift-Enter” and call it again.
The other way to make things consistent is “Kernel → Restart and Clear Output” followed by “Cell → Run All”.
Also note that every time you close and reopen the notebook, you have to run all the cells again. The output may be sitting there but the runtime version of the code is not loaded.
Glad to hear you found the solution. The point is that it’s not just that you need to execute the cell: the code also needs to be correct. You also need to be sure to run all the previous cells by doing “Cell → Run All Above” so that all the referenced support and test functions are imported for use.
~/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.
As suggested, I have run cell containing below code first (I have used Run command, upon getting error mentioned above, I cleared the output by running
“Restart kernal and clear all output” than run individual cells, but I am getting same error.
Your code is incorrect. What you have implemented as sigmoid(x) is just e^x. But the formula is a bit more complicated than that, right? When they said to use math.exp, they didn’t mean that was all you needed. That’s just the way you implement the exponential function. Please have another look at the formula they show that is the definition of the sigmoid function.