How I know the dim of the parameters of the w and b for initialization?

In course 1, week 2 assignment" Logistic Regression with a Neural Network mindset"
#Exercise 8 - model
how I know the dim of the parameters of the w and b for initialization?
I am using w, b = initialize_with_zeros(dim)

Hi malsharawy,

Welcome to the community and thanks for your question! Let me give you a hint: look at the arguments of the model function shown in red in your exercise. There you will see the different inputs for the function defined along with their shape. Think about which argument the w and b variables are using. If you know that, then you can determine the shape as well. Good luck and let us know whether you can find the answer!

Regards, Stephanus

1 Like

Dear Stephanus,
Thanks for your answer , i am not sure i got the right answer but it gives me now wrong values and wrong type for dw and db , here is the error

AssertionError Traceback (most recent call last)
----> 1 model_test(model)

~/work/release/W2A2/ 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’]}"
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.28154433]
[ 0.13142694]
[ 0.20526551]] != [[ 0.00194946]
[-0.0005046 ]
[ 0.00083111]
[ 0.00143207]]

can you give me a hint?

Hey got the same issue, check the func model parameters against the func optimize parameters.
You might want to review how you are calling the optimize function on model.

Thank you , IS THE X_train.shape = 4 in model ? as i understand it should be 12288

Hi, when model_test(model) is called X_train.shape is not 4, it is (4, 3), you can easily check it just by printing its shape inside the model function.

I don’t know if you have already solved the other errors but you could debug them just by comparing the expected output with the one you have, for example, starting with d['w'], that should be of type np.ndarray, so check what’s the type of w anywhere you are using it, because that’s basically what is assigned to d['w'] in the dictionary d.

1 Like

it is solved thank you , i was having a typo error

Cool, keep the good work :wink:

Good to hear it’s solved!