I have passed all the tests prior to this and cannot think of any reason this error would occur. Please help thanks
I have same problem as:
AssertionError Traceback (most recent call last)
in
----> 1 model_test(model)
~/work/release/W2A2/public_tests.py in model_test(target)
117 assert type(d[‘w’]) == np.ndarray, f"Wrong type for d[‘w’]. {type(d[‘w’])} != np.ndarray"
118 assert d[‘w’].shape == (X.shape[0], 1), f"Wrong shape for d[‘w’]. {d[‘w’].shape} != {(X.shape[0], 1)}"
→ 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’]}"
AssertionError: Wrong values for d[‘w’]. [[0.]
[0.]
[0.]
[0.]] != [[ 0.00194946]
[-0.0005046 ]
[ 0.00083111]
[ 0.00143207]]
any idea?
Another student had a similar issue: (Week 2 - ex 8) Merge functions
But the post did not help me find a solution. If anyone figures it out please let me know.
Note that your incorrect w values are all zeros, so your problem is not the same as that shown by @theo. So how could w end up as zero? That would indicate you only called the initialization routine from model and never did the “optimize” step.
Your incorrect w values are seen pretty frequently. I think it means you made one of the common errors of “hard-coding” the values of either learning rate or number of iterations when you call optimize from model.
Actually you will find the answer if you search for 0.28154433. Here’s a post that shows the solution. You probably didn’t pass all the parameters to optimize.
Thank you for your help. You were correct, I did not pass all the parameters to optimize. It works now.
That’s good news! Thanks for confirming.
Thank you, your answer helped me find that I must assign w= and b= separately not hardcoded as ‘params[“w”]’.
@mrshahabi , I’ve had the same problem. But I didn’t understand what you said. What does it mean to assign w and b separately? How can I do that?
add two more line as follows for ex:
w = param…
b= param…
I first hardcoded the as pram["W’] but that went wrong