W3_A1_Ex-8_nn_model_wrong values for W1

Hi,

I tried implementing the Exercise 8 - nn_model, but I am getting the same value for cost. The indivual Exercises are all correct. Could someone kindly help me.

Since the cost doesn’t change, there must be something wrong with how you are updating the parameters. Since your update_parameters function passed the tests, the bug must be in how you are calling it. E.g. do you pass 0 as the learning rate? Or do you perhaps pass it the wrong dictionary for either the parameters to be updated or the gradients? Or maybe you assign the return value to the wrong variable name? It’s that kind of bug that you are looking for: what are you doing in nn_model that would cause the parameters not to change? You can even print W1 every 100 iterations and see if it is changing at all or only just a tiny amount.

This is how debugging works: you have to reason from the results and work your way backwards to the cause. If what is happening with the results is mysterious, you can start by investigating that to generate more clues about the nature of the problem. It is a completely different case if the parameters are literally not changing at all versus changing only a tiny amount, right?

Dear @paulinpaloalto Thank you for your answer. It really helped. Eventhough I was trying to investigate the solution for a day, the way I approached the debugging was not systematic. Your advice helped me in identifying the bug and resolving the bug logically.

I had implemented the

Gradient descent parameter update. Inputs: “parameters, grads”. Outputs: “parameters”.

But I did not retrieve the parameters. So every time when the loop ran, the code was running with the same parameters instead of the updated parameters.

That’s great to hear that you were able to find the answer just based on those hints. Debugging is a skill and the key is being able to reason from the evidence so that you can focus your attention in a useful direction. Nice work!

1 Like