Week 2 Exercise 7 Issues

I keep on receiving this error and can’t seem to figure out why. I set A equal to the equation and I’m pretty sure I set the Y_predictions equal to the right values depending on the conditional. Any form of help would be much appreciated.

predictions = [[1. 1. 1.]]

AssertionError Traceback (most recent call last)
in
4 print ("predictions = " + str(predict(w, b, X)))
5
----> 6 predict_test(predict)

~/work/release/W2A2/public_tests.py in predict_test(target)
88 assert pred.shape == (1, X.shape[1]), f"Wrong shape for pred. {pred.shape} != {(1, X.shape[1])}"
89 assert np.bitwise_not(np.allclose(pred, [[1., 1., 1]])), f"Perhaps you forget to add b in the calculation of A"
—> 90 assert np.allclose(pred, [[1., 0., 1]]), f"Wrong values for pred. {pred} != {[[1., 0., 1.]]}"
91
92 print(’\033[92mAll tests passed!’)

AssertionError: Wrong values for pred. [[0. 0. 0.]] != [[1.0, 0.0, 1.0]]

It looks like all your predictions are 0. So the first question is to check your A values. I added some print statements to my code to see the A value and then the predictions before they are returned. Here’s what I get running the test cases in that cell:

A = [[0.52241976 0.50960677 0.34597965]]
predictions = [[1. 1. 0.]]
predictions = [[1. 1. 0.]]
A = [[0.72445526 0.46920652 0.55395658]]
predictions = [[1. 0. 1.]]
All tests passed!

Whoops nevermind! I found I accidentally typed 1 instead of i, thanks for the help!

1 Like

Cool! I’m glad to hear you found the solution. Onward! :nerd_face: