Week 2, exersice 8

Hi everyone!
My problem is that all previous tests have passed, exept for the model fuction.
Mysteriously, the costs is correct, but the w and b are not.
Would really appreciare your help!

Don’t use the default parameters for optimize. Look at the parameters for the method model and use them.

I’ve already tried this, but then the costs becomes a big array and w is still wrong

Please click my name and message your notebook as an attachment.

That means you are ignoring the parameters passed into model for the learning rate and number of iterations. When you call optimize from model, you must be passing different values than the actual values requested. There should be no equal signs in the parameter list that is passed to optimize, right?

Yes, I’m only passing values 2000, 0.5, False, taken from the model function to optimize, if I correctly understood you)

Here are 2 hints:

  1. The dimension you pass to initialize_with_zeros should be inferred from X_train
  2. The parameters you use when calling optimize should be taken from function parameters and not hardcoded.

I think you are missing the point here. Those are simply the default values given in the definition of the model function. That’s what will be used if you don’t pass those arguments to model. But the test case does pass those arguments and the values passed are not 2000 and 0.5. So how do you cope with that?

The way you wrote the code, the values passed to optimize will always be the same regardless of what is actually passed into model. That is what Balaji meant by “hardcoding”. It’s always a bad idea. My guess is that you are fairly new to python and are not familiar with how “named parameters” work. It might be worth googling “python named parameters” and having a look at some tutorials.

Thanks a lot, it completely fixed my problem!