Week 2 programming HW: exercise 8: Model

Hi,

All my tests have passed up until exercise 8, the model. It does not approve the “w” outcome of the model. Apparently the outcome of my model is different that what is expected.

AssertionError: Wrong values for d[‘w’]. [[ 0.14449502] [-0.1429235 ] [-0.19867517] [ 0.21265053]] != [[ 0.08639757] [-0.08231268] [-0.11798927] [ 0.12866053]]

All I do in that cell is to call the optimize function and set w as


w = params[‘w’]
I am confused since all of the earlier cells have passed their tests successfully. Any pointers on where I could have got wrong?

It means your logic in the model function itself is wrong. Just because your previous functions are correct doesn’t prove anything about your model logic: a perfectly correct function will produce bad results if you pass it bad arguments, right?

The most common errors are:

  1. referencing global variables instead of the parameters passed to model.
  2. hard-coding some of the parameters when you call optimize from model. E.g. hard-coding the learning rate or number of iterations, thus ignoring what is actually being requested for those parameters.

Thanks @paulinpaloalto You were absolutely right. Not sure why I made such a funny mistake. Thanks for the help.