Help with the course1 week 2 Lab

Hello everyone,
as I try to get all the written functions together, and call it a day, I face this error:


AssertionError Traceback (most recent call last)
in
1 from public_tests import *
2
----> 3 model_test(model)

~/work/release/W2A2/public_tests.py in model_test(target)
131 assert type(d[‘w’]) == np.ndarray, f"Wrong type for d[‘w’]. {type(d[‘w’])} != np.ndarray"
132 assert d[‘w’].shape == (X.shape[0], 1), f"Wrong shape for d[‘w’]. {d[‘w’].shape} != {(X.shape[0], 1)}"
→ 133 assert np.allclose(d[‘w’], expected_output[‘w’]), f"Wrong values for d[‘w’]. {d[‘w’]} != {expected_output[‘w’]}"
134
135 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.14449502]
[-0.1429235 ]
[-0.19867517]
[ 0.21265053]] != [[ 0.08639757]
[-0.08231268]
[-0.11798927]
[ 0.12866053]]

All the previous functions have passed the tests and my code for this part is:

{moderator edit - solution code removed}

anyone has any idea what may cause the problem?

The way you are calling optimize from model is incorrect. Think about it: what number of iterations will be passed to optimize? It will always be 100, regardless of what value the test case asks for when it calls model. And similarly with the learning rate: you are ignoring the values that are being requested and hard-coding them to those particular values.

That will not end well, as you see :nerd_face:

1 Like

Oh, I didn’t notice that!
Thank you!