Week 3 assignment: bug in the test

Hi @eeshita_pande,

You have incorrect implementation of the variable cost in your Ex 5.

Best,
Mubsi

1 Like

I’m seeing a similar issue where compute_cost_test_case is not returning results in expected shapes.

The following cell returns (1,3) and (1,400) while A2 is expected to be (1,400) as well.

A2, t_Y = compute_cost_test_case()
print (A2.shape)
print (Y.shape)

Lab ID : ejyowuhq

Thanks

1 Like

Hi @_daohang,

My apologise for replying this late. I was on a vacation. But I’m back now. Is this something you still need help me ? Let me know.

Thanks,
Mubsi

1 Like

That means there is a bug in your code: you must be referencing global variables instead of the actual parameters passed into your function.

1 Like

While I still believe there was something wrong in the provided code testing this specific function but I’m good now.

  • the final part combining all sub routines worked pretty well so that func shall have worked well.
  • losing the points for that specific function fortunately didn’t block ‘passing the assignment’.

So I unblock myself quickly from it. Thanks.

1 Like

Hi @Mubsi I am getting error in Week3 exercise 6 in backpropagation calculation of dZ1

can you help me what wrong I am doing … lab id ebxwifkh

regards,
Jitendra

1 Like

Mubsi is a pretty busy guy, so it’s worth investing a little more effort in trying to debug this yourself. What is the error that you are getting? Please show us the output, including the full exception trace if that’s what happened.

1 Like

@paulinpaloalto
I am getting error of wrong value of dW1

dW1 = [[-0.00022433  0.00055688]
 [-0.00501012  0.01245478]
 [ 0.00023946 -0.00059417]
 [ 0.00290866 -0.00721879]]
db1 = [[-0.00013131]
 [-0.00293254]
 [ 0.00014001]
 [ 0.00170148]]
dW2 = [[ 0.00078841  0.01765429 -0.00084166 -0.01022527]]
db2 = [[-0.16655712]]

AssertionError Traceback (most recent call last)
in
7 print ("db2 = "+ str(grads[“db2”]))
8
----> 9 backward_propagation_test(backward_propagation)

~/work/release/W3A1/public_tests.py in backward_propagation_test(target)
177 assert output[“db2”].shape == expected_output[“db2”].shape, f"Wrong shape for db2."
178
→ 179 assert np.allclose(output[“dW1”], expected_output[“dW1”]), “Wrong values for dW1”
180 assert np.allclose(output[“db1”], expected_output[“db1”]), “Wrong values for db1”
181 assert np.allclose(output[“dW2”], expected_output[“dW2”]), “Wrong values for dW2”

AssertionError: Wrong values for dW1

expected output:

dW1 = [[ 0.00301023 -0.00747267]
 [ 0.00257968 -0.00641288]
 [-0.00156892  0.003893  ]
 [-0.00652037  0.01618243]]
db1 = [[ 0.00176201]
 [ 0.00150995]
 [-0.00091736]
 [-0.00381422]]
dW2 = [[ 0.00078841  0.01765429 -0.00084166 -0.01022527]]
db2 = [[-0.16655712]]

I did the same steps as mentioned to calculate dZ1

{moderator edit - solution code removed}

1 Like

Please look more carefully at the formula for dZ1. Your code does not match what the formula says.

1 Like

thanks @paulinpaloalto I found the mistake in my code.

1 Like

@Mubsi or @paulinpaloalto, I’m seeing an issue with Week3’s assignment in compute_cost where my expected output is correct but I’m getting an AssertionError for the tests. Could either of you please take a look and let me know how I’m messing things up? Thank you!

My lab ID is gracrakw

1 Like

Mubsi can look at your lab, but the mentors cannot. Please show us the actual exception trace that you get when you run the test. If the assertion is failing, that means something is wrong with your output. The first step is to understand what the failure message is telling you. Mubsi is a busy guy, so it’s better not to depend on him doing your debugging for you.

1 Like

@paulinpaloalto, thank you for your response. The output is as follows:

cost = 0.6926858869721941
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-65-9523b300d7a7> in <module>
      3 print("cost = " + str(compute_cost(A2, t_Y)))
      4 
----> 5 compute_cost_test(compute_cost)

~/work/release/W3A1/public_tests.py in compute_cost_test(target)
    124 
    125     assert type(output) == float, "Wrong type. Float expected"
--> 126     assert np.isclose(output, expected_output), f"Wrong value. Expected: {expected_output} got: {output}"
    127 
    128     print("\033[92mAll tests passed!")

AssertionError: Wrong value. Expected: 0.5447066599017815 got: 1.0493608309109266

Expected output

cost = 0.6930587610394646

Seems the test case isn’t passing. I didn’t, however, hardcode anything and all of the rest of my code passes. Not quite sure what I’ve done wrong. Should I copy and paste my code?

1 Like

It looks like you’ve made one of the more popular mistakes on this one: you took the “sample code” that they gave you and assumed it was the complete solution. It’s not. Please compare your code to the math formula for the cost and ask yourself:

  1. What happened to the factor of \frac {1}{m}?
  2. Why is there only one term? What happened to the Y = 0 term?
4 Likes

Also note that your expected output is not correct. It differs starting in the third decimal place. That is not a rounding error: it’s a real error. Rounding errors start in the 15th or 16th decimal place typically (depending on exactly what the computation is).

1 Like

@Mubsi I got similar issue,
although passing all tests, all my values looking exactly as desired outputs, I couldn’t find hidden cells and I get grade of 88/100

I also couldn’t find my lab ID…
thanks,
Sheli

1 Like

Hi @Sheli_Kohan,

Can you download your notebook and send it to me in a direct message ?

Thanks,
Mubsi

1 Like

Hi,
Similar issue to other posters here. All tests have passed, but i get 88/100. I dont think Lab ID is visible in my assignment URL.

In my opinion grader should point to the function were error was made for students to figure out solutions themselves.
PS. I have commented out all optional code blocks as was suggested in other thread. Before that grader timed out.
Regards,
Michal

1 Like

Hi Genpj,

Kindly share the grader output what being displayed at when you submit your solutions.

Thanks!

1 Like

Hello, @Mubsi - getting the following output with the assignment grading tool:

All test are passed in the notebook and lab id is bawxcmkh.
Can you help me out ? Thanks

1 Like