Hi everyone,
I got stuck on exercise 8 of the programming assignment in week 2. I keep getting the following error and don’t know what to do with it. I would appreciate your help!
Hi everyone,
I got stuck on exercise 8 of the programming assignment in week 2. I keep getting the following error and don’t know what to do with it. I would appreciate your help!
Maybe your input argument to initialize_with_zeros
in model function
is incorrect. It should be the number of rows of X_train
.
Best,
Saif.
That error is telling you that your w values are not correct after doing the number of iterations of training that was specified in the test case. If all your previous functions like optimize
passed their test cases, then the first thing to check is that you did not “hard-code” any parameters when you called optimize
from model
. There should be no equal signs in the parameters you are passing and you need to make sure to pass all the parameters. You can’t omit the learning rate, number of iterations and print flag, because that would mean you are using the default values declared in the definition of optimize
, instead of the actual values being requested by the test case.
You can look at the code in the model_test
function by clicking “File → Open” and then opening the file public_tests.py
. What you’ll find is that the test case uses 50 iterations and a learning rate of 0.01. But the default values declared in the definition of optimize are 100 iterations and LR of 0.009. So you will get a costs
array with one element in both cases, but you get the wrong answers for w and b because everything else is different if you omit the “keyword” parameters on the call to optimize
.
Thank you so much for your reply! I have managed to get it right!