Week 2 Exercise 8 cannot pass last test but results seems reasonable and no error

Hello,
I have an issue with week 2 assignment. I am able to run the final result and get 99% for training set and 68% on testing set. But somehow I cannot pass the last testing. I don’t know where the problem is. I submitted anyway but I didn’t get 100% of the score.

The error was:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-19-9408a3dffbf6> in <module>
      1 from public_tests import *
      2 
----> 3 model_test(model)

~/work/submitted/courseraLearner/W2A2/public_tests.py in model_test(target)
    127     assert type(d['Y_prediction_test']) == np.ndarray, f"Wrong type for d['...
    128     assert d['Y_prediction_test'].shape == (1, x_test.shape[1]), f"Wrong sh...
--> 129     assert np.allclose(d['Y_prediction_test'], expected_output['Y_predictio...
    130 
    131     assert type(d['Y_prediction_train']) == np.ndarray, f"Wrong type for d[...

AssertionError: Wrong values for d['Y_prediction_test']. [[1. 0. 0.]] != [[1. 1. 0....

It is hard to tell anything else besides that your model is predicting [1,0,0] when it should be predicting [1,1,0]. I guess you are on exercise 7. I would print() the values of some of the variables on the predict function to se what is going on. For example, print(str(A[0,i])) inside the for loop should show you what are the exact probabilities you are predicting and A[0,1] should be showing some value smaller then 0.5 when it should be greater.

I have the same problem and my codes passed all the previous tests

I have the same problem and My codes for exercise 7 passed all the test.

I had the same problem but it was a silly mistake. What happened to me is that in exe 7 where I need to write if A [0,i] > 0.5: Y-prediction[0,i] = 1 else: Yprecition[0,i] = 0, I wrote Y_prediction[0,1] = 0. Wish you did not make the same mistake.

1 Like

I had the same problem and it drove me crazy.

The problem for me was in the predict() function above, although it passed all tests despite being incorrect.

When I computed A, I forgot the to wrap it in the activation sigmoid function and I also forgot about b… Very embarassing. I guess I was rushing through the code and relied to much on the tester function to catch my mistakes.

[quote=“jalvespinto, post:2, topic:24775, full:true”]
It is hard to tell anything else besides that your model is predicting [1,0,0] when it should be predicting [1,1,0]. I guess you are on exercise 7. I would print() the values of some of the variables on the predict function to se what is going on. For example, print(str(A[0,i])) inside the for loop should show you what are the exact probabilities you are predicting and A[0,1] should be showing some value smaller then 0.5 when it should be greater.