Hi, I’m stuck for a week with it, and have no clue what am I doing wrong.
In the exercise 2, where we calculate sigmoid with “math”, the test it passed. When I’m using the same formula, but for np.array type (using np.exp(x)), it says the output is wrong.
I did a check in PyCharm this way:
print(str(sigmoid_math(1)))
x = np.array([1, 1, 1])
print(str(sigmoid(x)))
Where sigmoid_math(x) is a function calculating sigmoid with math.exp(x), and sigmoid(x) calculating it with np.exp(x). I’m getting following output in PyCharm, that looks to be correct:
0.7310585786300049
[0.73105858 0.73105858 0.73105858]
But in the assignment It says “wrong output”.
sigmoid(t_x) = [0.73105858 0.98201379 0.99987661]
Error: Wrong output.
2 Tests passed
1 Tests failed
AssertionError Traceback (most recent call last)
in
2 print("sigmoid(t_x) = " + str(sigmoid(t_x)))
3
----> 4 sigmoid_test(sigmoid)
~/work/release/W2A1/public_tests.py in sigmoid_test(target)
49 ]
50
—> 51 test(test_cases, target)
52
53
~/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 sigmoid. Check your equations and avoid using global variables inside the function.