W2_A2_Ex-8_Merge All Functions into a model

Hi everyone, I am getting the following error with my code. Could anyone help me to figure out my mistake? I have initialized the weight vector as w = initialize_with_zero(X_train.shape[0]).

Thank you!


AssertionError Traceback (most recent call last)
1 from public_tests import *
----> 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’]}"
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.21265053]] != [[ 0.08639757]
[ 0.12866053]]


Hello Marcy,

Welcome to the community.

Please check on how you are passing the parameters to call the optimize function.


Hi @Marcy_Audrey_Demafo,
Welcome to the community.
Doesn’t look any problem with weights initialization here. Could you please check if you have initialized bias (b) in the same way ?

As your shape of d[‘w’] is the same as expected but the values are change, it means that there is some mistake in calculating the dw or A or cost or all. Are you sure you’ve passed all the above tests?


Hi everyone, many thanks for your reply. A special thanks to @Rashmi for bringing my attention to that point. The problem was the optimize function which I was calling wrongly. Everything works nicely now.

I am pleased about this first graded assignment because I could do it on my own and learned many things as well. I always thought that DeepLearning is not for me but I realize now that it’s a matter of being logical.

I am more excited about the upcoming assignments and I wish many successes to all those taking these courses as well. Thank you very much :slight_smile:

Glad to know that Marcy!

Rise & Shine!