C1_W3 Getting the initial values right, but not the test values

for UNQ_C3
I’m able to get the values right for both dj_dw and dj_db at the initial w, b values (zeros).

However, for the test values it is getting very close to the right answer, but not exact. I don’t know how this happened or what I need to fix.

There is an error in your code’s calculation of dj_db.
Be sure you have read all of the hints in the notebook for this function.

I have read all the hints and applied everything, but what could make the value so close to the correct answer but still be wrong?
@TMosh I have looked at the code again, there seems to be nothing wrong with dj_db (as far as I know) and it matches the hint exactly

like how Tom mentioned your code implementation for dj_db and dj_dw is incorrect

you have added an extra code line of dj_db_i and then applied that code to dj_db which you need to write in a single code line.

Same goes for dj_dw, check the below post comment, it should help you

Which line are you referring to as “extra”?
image
these are the two lines for dj_db and I only have those in my code, and they are implemented as the hint below suggests.
I am really confused about which part I’m doing wrong. Appreciate your help

you probably recalled dj_db_i and then
dj_db += dj_db_i

this should be recalled dj_db += (the value of of dj_db_i)

according to the below image

can I show you my code?

send me via personal DM. Click my name and then message. posting code on public post thread is against community guidelines

This function is much easier to implement if you use numpy matrix mathematics, rather than a set of for-loops.

You are correct indeed.but do I have to vectorize the inputs or is that already done?
Also, would there be a difference for dj_db? since its only subtraction of vectors.

You do not need to modify the inputs.
There are equations for dj_dw and dj_db. You just have to implement them.

1 Like