C1W2_Assignment_2_EX8_Model_Value Error

Hello,

I have been reading a lot of the previous post and i couldnt find one that explained clearly my situation though some are similar. So i created a new post here. All my functions before model function passed.

When i run Model function, i m getting a value error which states that the W cannot be reshaped which is an assignment in the predict function.

I dont know what i m doing wrong, i assume i m making a mistake in the model function. Can someone help me by point me in the correct direction by explaining why its causing an issue…

Yes, the error is in your model function.

Look at lines 39-40 in your traceback. Check what you’re passing as the third argument to predict. The function signature is predict(w, b, X), so that third argument needs to be a feature matrix with shape (n_x, m).

Now look at your printed shapes: Y_test has shape (1, 3), which means shape[0] = 1. Your w has 4 elements. That’s where the mismatch comes from: you’re passing something with 1 row to a function that tries to reshape a 4-element w to match X.shape[0].

Think about which variables should go into predict : the features or the labels?

Hello Arman,

Thank you for the replying to my post and the explanation. My mistake. You are correct, i passed the Y_test and Y-train as the arguments for function call which is a vector than an expected matrix. Matrix should be features than variable. I got confused by the Assignment Name and thought I should pass Y_test and Y_train for Y_predictions. Thank you for your help. All Cells are now correct and assignment submitted.