W3 programming assignment infinite cost

I am currently struggling with the nn_model function of this week’s programming assginment. In all my previous ffunctions, it passed all the test case that was thrown at the function, but however, when I tried putting everything all together, the cost keeps increasing to infinity. Can someone give me any tips on how to fix this issue?

Post your full error.

here is my code for the nn_model

{moderator edit - solution code removed}

You misspelled the variable name that is returned from backward_propagation, so the gradients are incorrect. When you reference them in the update_parameters step, you are picking up a global variable that has nothing to do with the actual values you should be using.

my code for other function

{moderator edit - solution code removed}

If the other functions passed their test cases, then the most likely scenario is that the bug is in nn_model and I think my previous reply pointed to the cause.

Also please note that the course Honor Code (documented in Week 2) says that we can’t share our solution code here or in any other public way. If the mentors can’t figure out how to help by seeing your error output, we will contact you privately by a DM (Direct Message) to see your code in a non-public way. No harm is done in this case, because I edited your posts to remove the source code, but please keep that in mind for any future questions.