Week_3 Programming Assignment - Function 'predict' is incorrect

Hola !

Even though the Output of predict value is as expected (Function ‘predict’), I got this point incorrect. That causes me less earn points to pass. Would you mind helping me to figure this point out?


Code Cell UNQ_C4: Function ‘predict’ is incorrect. Check implementation.


Hi Carlos,

Please share your code for UNQ_C4 on Direct Message :slight_smile: I can take a look!


Hello Carlos,

Seems you used both the vectorization approach and the for-loop approach to double calculate z_wb. Please see if this is the problem?


Got it. It’s fixed. Thanks, Raymond!

You are welcome Carlos!

Hi @rmwkwok,
I have the same problem as Carlos but I think that I implemented z_wb correctly.
I can’t find a solution that solves my problem on other posts.
Can I send you my notebook on Direct Message please ?

Hi @Dalila, is your problem about UNQ_C4? If so please send me the code for UNQ_C4 first on direct message, I will ask for the notebook if needed.

@rmwkwok ,yes, my problem is about UNQ_C4.
I just sent you the code on direct message.
Thanks for your responsiveness :slight_smile:

Thank you @Dalila, there is a problem in the line for adding bias, please check if you need “+=” or “=”.


You were right, my problem was with the bias. I fixed it.
Thanks Raymond !

You are welcome Dalila!

1 Like

I have a problem with UNQ_C4 can you help me ?

@EitharOqayli, and can you please also just share the error message here?

File “”, line 19
m, n = X.shape
IndentationError: unexpected indent

I see. I suggest you to use 4 white spaces for one level of identation. For example:

def predict(X, w, b): is in the zero-th level of indentation, so you don’t need any white spaces before it.
Anything inside the predict will be at least in the first indentation level which will all be indented by at least 4 white spaces.
You have two for-loops.
Anything inside the outer for-loop will be in the second indentation level which takes 8 white spaces.
Anything inside the inner for-loop will be in the third indentation level which takes 12 white spaces.

To set all lines to zero-level, select those lines, press “Shift + Tab” once and it will go 4 white-space backward, you can keep pressing it until all go back to the zero-th level, then select the lines you want to move one indentation level up, and press “Tab”, and repeat this step until all indentations are alright.

thank you so much that worked perfectly :heart:

You are welcome @EitharOqayli!