All tests passed but prediction incorrect?

Hi,
In the logistic regression assignment of week 2, I have passed all tests before exercise 7 but it is apparently giving wrong predictions [[0. 0. 0.]].

Kindly share the full error.

Best,
Saif.

Have you made some changes to the pre-coded code of the predict function?

Mine looks like this:

# Compute vector "A" predicting the probabilities of a cat being present in the picture
    #(≈ 1 line of code)
    # A = ...
    # YOUR CODE STARTS HERE
    
    # YOUR CODE ENDS HERE
    
    for i in range(A.shape[1]):
        
        # Convert probabilities A[0,i] to actual predictions p[0,i]
        #(≈ 4 lines of code)
        # if A[0, i] > ____ :
        #     Y_prediction[0,i] = 
        # else:
        #     Y_prediction[0,i] = 
        # YOUR CODE STARTS HERE
        
        # YOUR CODE ENDS HERE
    

How is yours?

Yes, I had the same question that Saif has. Also note that we can see a little snippet of the core part of the code in your first post and that all looks correct. The other thing to check is that you computed A correctly. Are you sure you didn’t reference global variables instead of the parameters and remembered to include the bias value and the sigmoid call?

One other possibility is that you fixed the predict code, but didn’t actually click “Shift-Enter” on that cell to get the new code loaded into the runtime image. You can make sure everything is consistent by clicking:

Kernel → Restart and Clear Output
Save
Cell → Run All Above

Then run the predict test again. In other words in my last theory, the code you are actually running is not what we are looking at.

Check your A. You need to apply sigmoid.

Best,
Saif.

Kindly delete your code.