The problem is not in the test cell: the problem is that your actual code is wrong. You need to debug your code. That particular set of incorrect values for w probably means that you hard-wired some parameters on the call from model to optimize.
I am having the same issue I tried to debug the code but I am able to understand. first I had hard-wired some parameters but then I changed them. number of iterations are 100 and learning rate = 0.00005, Then I am getting this error!!
AssertionError Traceback (most recent call last)
in
----> 1 model_test(model)
~/work/release/W2A2/public_tests.py in model_test(target)
119 assert np.allclose(d[‘w’], expected_output[‘w’]), f"Wrong values for d[‘w’]. {d[‘w’]} != {expected_output[‘w’]}"
120
→ 121 assert np.allclose(d[‘b’], expected_output[‘b’]), f"Wrong values for d[‘b’]. {d[‘b’]} != {expected_output[‘b’]}"
122
123 assert type(d[‘Y_prediction_test’]) == np.ndarray, f"Wrong type for d[‘Y_prediction_test’]. {type(d[‘Y_prediction_test’])} != np.ndarray"
AssertionError: Wrong values for d[‘b’]. 0.0008311670001839005 != 0.000831188
Hi,
I had the same issue. So, is it always the rule that we don’t hard-wire the parameters when we call a function? For example, model(…, num_iterations=2000,…).
Right! You only specify the values at the top level, whatever that is. Of course these parameters are optional, so in some cases the default values at the lower level will be applied. But you normally only specify the hard-coded value like that in the function definition, where it has the effect of declaring the default value. Defining (declaring) a function is a whole different thing than invoking (calling) a function, right?
I have the same errors, I tried the use the same values of num_iterations, learning_rate, print_cost, as in the optimize function but nothing changed.
I still have the error. Is that the way you corrected yours or what could I be doing wrong?
The point is that you should not “hard-code” any parameters inside the body of the model function. In particular, when you call optimize from model, there should not be any “=” equal signs in the parameter list you are passing down to optimize.