W2_A2_Ex-6_Assertion Error_Propagate Function

I am stuck at week 2 graded assignment exercise 6 “Optimize” function.
I am sure that my code is correct but it is giving Assertion Error. The propagate function works fine. Please help me.
Below are propagate and optimize codes:

{moderator edit - solution code removed}

—> 37 grads, cost = propagate(w, b, X, Y)

in propagate(w, b, X, Y)
35 ### END CODE HERE ###
—> 37 assert(dw.shape == w.shape)
38 assert(db.dtype == float)
39 cost = np.squeeze(cost)


Your optimize code doesn’t show how you retrieve derivatives (dw and db) from grads.

dw = grads[“dw”]
db = grads[“db”]

Hi @Shreshth_Dhawan ,

The multiplication operator is * in python.
Please rewrite the code for the cost calculation using the mutiplication operator.

Your code for the “update parameters” logic is incorrect. Please have a more careful look at it. The incorrect update is the reason that the shapes end up going bad. I’ll bet if you print the shape of dw, you’ll find that it’s correct on the first iteration and then mutates after that. :scream_cat:

Note that we aren’t supposed to share solution code in a public way. But when you show any kind of code you need to use the </> formatting tool, so that the code doesn’t get interpreted as “markdown”. For example * means italic in markdown, so the code is not really legible as code. I edited the post twice: once to format the code so that I could really “see” it and then again to remove the code. You should be able to see my edits if you click the little edit pencil to see what I mean about the markdown.

Thank you for your help. I can see the shapes changing. I will be careful with solution code from now onwards.