When creating a post, pleaseHello,
I am having trouble implementing the method “model” with Excersize 8 on Lab1 week 2.
I initialized w and b using the initialize_with_zeros method w of shape (4 ,1).
I called optimize passing in the other variables that were passed into model().
I passed X_train and Y_train into optimize() but I dont know if that is correct.
X is data of shape (num_px * num_px * 3, number of examples) and Y is a true “label” vector (containing 0 if non-cat, 1 if cat), of shape (1, number of examples).
Also I have a question with calling ther predict method with X_Test for Y_prediction_ test and X_train for Y_prediction_test
Here is my output:
#X_train
[[ 1.76405235 0.40015721 0.97873798 2.2408932 1.86755799 -0.97727788
0.95008842]
[-0.15135721 -0.10321885 0.4105985 0.14404357 1.45427351 0.76103773
0.12167502]
[ 0.44386323 0.33367433 1.49407907 -0.20515826 0.3130677 -0.85409574
-2.55298982]
[ 0.6536186 0.8644362 -0.74216502 2.26975462 -1.45436567 0.04575852
-0.18718385]]
[[0.]
[0.]
[0.]
[0.]]
({‘w’: array([[ 0.08639757],
[-0.08231268],
[-0.11798927],
[ 0.12866053]]), ‘b’: -0.039832360948163205}, {‘dw’: array([[-0.15608203],
[ 0.15736202],
[ 0.21618227],
[-0.22969068]]), ‘db’: 0.08648594658415165}, [array(0.69314718)])
[array(0.69314718)]
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)
127 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"
128 assert len(d[‘costs’]) == 1, f"Wrong length for d[‘costs’]. {len(d[‘costs’])} != 1"
→ 129 assert np.allclose(d[‘costs’], expected_output[‘costs’]), f"Wrong values for d[‘costs’]. {d[‘costs’]} != {expected_output[‘costs’]}"
130
131 assert type(d[‘w’]) == np.ndarray, f"Wrong type for d[‘w’]. {type(d[‘w’])} != np.ndarray"
AssertionError: Wrong values for d[‘costs’]. [array(0.15900538)] != [array(0.69314718)]