# W2 A2 | Ex-7 | Predict error

My code does not return the expected result. I return [[0. 0. 0.]] instead of [[1.0, 0.0, 1.0]]. So some silly format error.

But also I have inserted print statements to debug this. But I return only two values, and both A[i] are classified correctly .

Thank you!

See output:
Shape of A[0] (3,)
Shape of A[1] (3,)
Debug: Value of A 0 0.4532514150014657
Debug: Value of Prediction 0 0.0
predictions = [[0. 0. 0.]]
Shape of A[0] (3,)
Shape of A[1] (3,)
Debug: Value of A 0 0.4916682712877986
Debug: Value of Prediction 0 0.0

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)
100 assert pred.shape == (1, X.shape[1]), f"Wrong shape for pred. {pred.shape} != {(1, X.shape[1])}"
101 assert np.bitwise_not(np.allclose(pred, [[1., 1., 1]])), f"Perhaps you forget to add b in the calculation of A"
β 102 assert np.allclose(pred, [[1., 0., 1]]), f"Wrong values for pred. {pred} != {[[1., 0., 1.]]}"
103
104 print(β\033[92mAll tests passed!β)

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

Welcome to the community !

With looking at the dimension of A, it seems that A is not calculated correctly.
Here is the formula given in a notebook.

\hat{Y} = A = \sigma(w^T X + b)

In here, w^T X is a dot product of w^T and X. Please double check.

Thanks! You were right and I fixed Y hat.

You need to look at your trace very carefully. The answer is there.
Your code only touched the first element, and did not touch 2nd and third. As Y is initialized to zero, the result for the 2nd and 3rd elements are zero. It is obvious that your iteration count is not correct.
Please check the range of for-loop.

< Update >