Week 2 Exercise 5 propagate function

Hi!

i can’t find my error. Basically all my values are wrong, but I think my code is correct, please help me

{moderator edit - solution code removed}

dw = [[-0.00154399]
[-0.00492761]]
db = 0.0014555781367842193
cost = 0.0015453193941501516

AssertionError: Wrong values for grads[‘dw’]. [[-0.00154399]
[-0.00492761]] != [[0.99845601]
[2.39507239]]

1 Like

Interesting. The code that you show does seem correct, although the lines are not formatted correctly.

Are you sure your value of m is correct? You don’t show how you compute that.

1 Like

I came here to find answers for the same issue, and I’m getting the exact same output as this user.

As for m, though, m = X.shape[1] is provided by the prompt and is not user-defined

2 Likes

Hi!

The lines are not formatted because I pasted it wrong, sorry.
In the code it is correct.

The m was given and is m = X.shape[1]. It does seem to be correct also, since the dimensions are (num_px * num_px * 3, number of examples)

Thank you!

4 Likes

I am having the same problem. Seems to be correct code, but the output doesn’t match !

dw = [[-0.00154399]
[-0.00492761]]
db = 0.0014555781367842193
cost = 0.0015453193941501516

AssertionError: Wrong values for grads[‘dw’]. [[-0.00154399]
[-0.00492761]] != [[0.99845601]
[2.39507239]]

2 Likes

I printed m. Its only 3 !
Is the input vector X flattened?

1 Like

I am having the same problems as well. My output is exactly the same as user

2 Likes

I think this seems to be an issue from the developer’s end because I wrote the same code before the revision and got the tests passed and now the codes are just not working

2 Likes

I am having a similar problem. Have written the same code.

2 Likes

Hi,
I am also facing the same issue.
I tried calculating cost with for loop also but same issue

AssertionError Traceback (most recent call last)
in
14 print ("cost = " + str(cost))
15
—> 16 propagate_test(propagate)

~/work/release/W2A2/public_tests.py in propagate_test(target)
37 assert type(grads[‘dw’]) == np.ndarray, f"Wrong type for grads[‘dw’]. {type(grads[‘dw’])} != np.ndarray"
38 assert grads[‘dw’].shape == w.shape, f"Wrong shape for grads[‘dw’]. {grads[‘dw’].shape} != {w.shape}"
—> 39 assert np.allclose(grads[‘dw’], expected_dw), f"Wrong values for grads[‘dw’]. {grads[‘dw’]} != {expected_dw}"
40 assert np.allclose(grads[‘db’], expected_db), f"Wrong values for grads[‘db’]. {grads[‘db’]} != {expected_db}"
41 assert np.allclose(cost, expected_cost), f"Wrong values for cost. {cost} != {expected_cost}"

AssertionError: Wrong values for grads[‘dw’]. [[-0.00154399]
[-0.00492761]] != [[0.99845601]
[2.39507239]]

1 Like

Hi
I have the same problem

{moderator edit - solution code removed}

This is my code, but i gave the error of wrong results.
dw = [[-0.00154399]
[-0.00492761]]
db = 0.0014555781367842193
cost = 0.0015453193941501516

AssertionError Traceback (most recent call last)
in
14 print ("cost = " + str(cost))
15
—> 16 propagate_test(propagate)

~/work/release/W2A2/public_tests.py in propagate_test(target)
37 assert type(grads[‘dw’]) == np.ndarray, f"Wrong type for grads[‘dw’]. {type(grads[‘dw’])} != np.ndarray"
38 assert grads[‘dw’].shape == w.shape, f"Wrong shape for grads[‘dw’]. {grads[‘dw’].shape} != {w.shape}"
—> 39 assert np.allclose(grads[‘dw’], expected_dw), f"Wrong values for grads[‘dw’]. {grads[‘dw’]} != {expected_dw}"
40 assert np.allclose(grads[‘db’], expected_db), f"Wrong values for grads[‘db’]. {grads[‘db’]} != {expected_db}"
41 assert np.allclose(cost, expected_cost), f"Wrong values for cost. {cost} != {expected_cost}"

1 Like

@paulinpaloalto : I also faced the same issue. The value of Y in the public test.py and code that is graded is different.

2 Likes

I am facing the same problem. I’m sure my code is correct, but the tests fail. I also get the same values for dw, db and cost as the others who posted in this thread. Could this be happening because the grader was updated yesterday?

2 Likes

Only exercise 5 of the assignment is having a problem with the propagate function. If you have done the same way as mentioned in this post then the output corresponding to the propagate function is correct in the latter exercises of the assignment.
I completed the assignment and passed. Just ignored the output of exercise 5.

1 Like

I have the smae problem. However, i passed the exercise on July 17.
Today i want to review my exercise, I found my result became incorrect.
I guess the update on 23 July 2021, 2:55 PM PST maybe have influence on this.

1 Like

I managed to complete the exercise ignoring the output of exercise 5 as well. Got to discourse to report the problem and found this post :grimacing:

1 Like

Sorry! Yes, this breakage is caused by an update to the test cases yesterday. I just filed a high priority bug about the situation and hope the course staff will respond soon.

4 Likes

Hello. I want to inform that the problem has been solved. Probably you need to “forceRefresh” to get the fix working. The notebook and the public_tests.py files have changed.

Thanks for the quick report.

6 Likes

Thanks @andres.castillo for the very quick response on this! Yes, I have confirmed that the latest version that Andres just published works. Once you’ve gotten the new version of the notebook, you’ll need to “copy/paste” over just your completed code from your current version to the new version and then everything should work again.

3 Likes

Thanks a lot.The latest public_tests(10 hours ago) version works.

1 Like