W2_A2_Logistic Regression

All the former modules run smoothly. But the last module ends up with this error. I don’t know why it goes wrong.
Wrong values for d[‘w’]. [[ 0.14449502] [-0.1429235 ] [-0.19867517] [ 0.21265053]] != [[ 0.08639757] [-0.08231268] [-0.11798927] [ 0.12866053]]

A common type of mistake is to “hard-code” the values of some of the parameters like learning rate and number of iterations on the call to optimize from model. The high level point is that even if the lower level functions are correct, they can still malfunction if you call them with the wrong arguments. The first place to look for bugs is in your model function code.

Yeah I am having the same issue and had been through a very hard time to debug even I examine all the code I had written before. After that I found that the learning rate and the number of iterations was hard-coded because I just copy and paste the function call on above to avoid mistakes.

I am sorry to hear that. However, @Gehrman_Yu_74751Xiao, by Murphy’s law, we sometimes just can’t avoid it. My message won’t give you back the time you had spent, but I want to tell you it won’t mean nothing. You will be more aware of specifying input parameter values in the future, and you would be more aware of that you havn’t set some input parameters when it comes to debugging, and if you are to design a function, you would have your way to decide which variables should have a default and which shouldn’t. You can make it count!


Yes, as Raymond says, the knowledge may have cost you something in terms of time and frustration, but a lesson learned “the hard way” is more likely to be remembered. The general rule is defining a function is a completely different thing than calling a function, so you can’t just “copy/paste” and walk away. :nerd_face: