Model assertion error

{‘costs’: [array(0.69314718)], ‘Y_prediction_test’: array([[1., 1., 0.]]), ‘Y_prediction_train’: array([[1., 1., 0., 1., 0., 0., 1.]]), ‘w’: array([[ 0.14449502],
[-0.1429235 ],
[-0.19867517],
[ 0.21265053]]), ‘b’: -0.0759564065803776, ‘learning_rate’: 0.01, ‘num_iterations’: 50}

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)
121 assert type(d[‘w’]) == np.ndarray, f"Wrong type for d[‘w’]. {type(d[‘w’])} != np.ndarray"
122 assert d[‘w’].shape == (X.shape[0], 1), f"Wrong shape for d[‘w’]. {d[‘w’].shape} != {(X.shape[0], 1)}"
→ 123 assert np.allclose(d[‘w’], expected_output[‘w’]), f"Wrong values for d[‘w’]. {d[‘w’]} != {expected_output[‘w’]}"
124
125 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]]

Any inputs are appreciated!

1 Like

Fixed!

Solution use optimize(w, b, X_train, Y_train, num_iterations,learning_rate, print_cost)
instead of optimize(w,b,X_train,Y_train) while computing the hyper parameters and gradients

1 Like

@SUMAN_RAO_NEELKANT_R, also avoid hard-coding the variables.