W2_A2_Ex-8 The explain of parameter

Hello everyone!

I would like to share with you a small matter regarding exercise 8 requirement. I followed the description of parameter and write the code. So I am getting an error in exercise 8 model where it says: ValueError: shapes (1,12288) and (4,7) not aligned: 12288 (dim 1) ! = 4 (dim 0)

After a while of checking and re-run all previous exercise, i think my code is not wrong. I check file test and saw we were passing a random matrix (4,7) as X_train making the function wrong (false dimension). So, I changed the code to w, b = initialize_with_zeros(X_train.shape[0]) (i wrote initialize_with_zeros(num_px * num_px * 3) before) and passed all the test.

I think it will be better if we change the assess test value of X_train to (num_px * num_px * 3, num_train)? Or we can change the description of function’s parameter to avoid misunderstanding (like me :sweat_smile:).
Thanks, Happy Community :smile: :smile:

1 Like

Hi, Duong.

Welcome to the course!

The problem is that your initial version of the code in the model function was incorrect. You wrote it in a “non-general” way: rather than handle any shape of inputs for X_train, you are hard-coding the dimension that you pass to initialize_with_zeros to be 12288. We are always striving to write general code here that will work with any inputs, so it’s good to see that you were able to figure out the correct solution of using the shape of X_train.

But you do have a good point that the “docstring” description of the shape of X_train is misleading. I will file a bug with the course staff and suggest that they change the description.

1 Like