C1_W3_UNQ_C6 Assertion Error

  • Link to the classroom item you are referring to: C1_W3_UNQ_C6
  • Description: Receiving the following error:
    AssertionError Traceback (most recent call last)
    in
    11
    12 # UNIT TESTS
    —> 13 compute_gradient_reg_test(compute_gradient_reg)

~/work/public_tests.py in compute_gradient_reg_test(target)
122 dj_db, dj_dw = target(X, y, w, b, lambda_)
123
→ 124 assert np.isclose(dj_db, expected1[0]), f"Wrong dj_db. Expected: {expected1[0]} got: {dj_db}"
125 assert np.allclose(dj_dw, expected1[1]), f"Wrong dj_dw. Expected: {expected1[1]} got: {dj_dw}"
126

AssertionError: Wrong dj_db. Expected: -0.1506447567869257 got: -0.021520679540989386

I understand this means my figures are not matching. However, I’m not sure where I am going wrong. All my previous functions have passed the tests. I have read all the hints under the cell. I would like additional information in understanding this function and why my code is wrong.

Its probably inside the target function, especially where you compute the dj_db derivative or could even be in prior computations aiding this computation, so you have to check all that stream!

If all of my other tests passed prior to this function. How could any of them be incorrect?

Well there is some error somewhere, and the debugging starts from here…

The error is in your compute_gradient_reg() function.

I understand that much. I don’t know where I’m going wrong though. I need someone to help me understand WHERE I am going wrong. I’ve gone over the lecture videos more than once and need more guidance.

Everything you need to implement the code is in the notebook text. The videos can be misleading or have uncorrected errors.

Note that the “Click for hints” text below that function pretty much gives you the solution.

Sorry, but what may be easy for you to see isn’t easy for me to see. I need more help than that.

Have you read the hints?

I read the hints long before I made this post. I figured it out after some work. I think that particular question needs to be clearer. It’s misleading the way the function is structured and the way the hint is written.

1 Like