In exercise 7, the correnct Y_prediction output is [1 0 1], while, no matter what, I always got
A = [0.52241776 0.50960677 0.34597965]
also, in this case, Y_prediction should be [1 1 0], but I got [1, 0, 0] instead, which is very weird…
my code is very simple, A = sigmoid(np.dot(wT, X)+b), as sigmoid function was defined above in Exercise 3 (and All test passed is shownd); the threshold of Y_prediction of 0.5 is set. I got stuck for a while, please help!
Note: There are some other tests that are performed in the background when you run the predict_test(). It’s possible your code is failing one of those hidden tests.
You must be referencing global variables instead of the actual parameters that are passed to the function. Notice that in the test that fails, your prediction has 3 elements, but the expected value has 6. So you’re not using the correct input X value.
Thanks guys, it turns out that I accidentally added a Tab in front of the line “return Y_prediction” of predict function. As I removed the tab space, it shows all tests passed.
Key takeaway: space and Tab space matters a lot in python
the previous version (that made the bug) is shown as below: