Week 2 Log. Regr. Exercise 8 wrong values for Y_prediction_test

Hi I’m getting a failing Y_prediction_test values and I cannot fathom why. I’ve debug printed at each step and my optimize function is working, then i extracted the w and b from the params correctly (as compared with model_test.py)

Printed debug variables:
initialized w shape is (4, 1)
initalized b is 0.0
[[ 0.88202617 0.2000786 0.48936899]
[ 1.1204466 0.933779 -0.48863894]
[ 0.47504421 -0.0756786 -0.05160943]
[ 0.20529925 0.07202179 0.72713675]]
X_test shape (4, 3)
X_train shape (4, 3)
costs [array(0.69314718)]
w is [[ 0.00194946 -0.0005046 0.00083111 0.00143207]]
0.0008311888169172717
Y_prediction_test [[0.00267411 0.00079029 0.00303018]]
Y_prediction_train [[0.00451703 0.0007494 0.00522916]]

my prediction equations:

Y_prediction_test = np.dot(w.T, X_test) + b
Y_prediction_train = np.dot(w.T, X_train) + b

yet i’m still getting the wrong values:

AssertionError: Wrong values for d[‘Y_prediction_test’]. [[0.00267411 0.00079029 0.00303018]] != [[1. 1. 1.]]

any tips for me?

Hi @mast6580, I understand you are speaking of excercise 8, right? The prediction vectors are supposed to contain 0 or 1 that represent the decision weather that particular input is a cat or not. Note that earlier in the notebook, in section “Excercise 7 - predict”, you should have implemented a function that calculate exactly these types of predictions:

# GRADED FUNCTION: predict

def predict(w, b, X):
    '''
    Predict whether the label is 0 or 1 using learned logistic regression parameters (w, b)

Hope this can help you

2 Likes