W2_E8: Define w,b - ’ValueError’ shapes not aligned

Reference: numpy.ndarray.size — NumPy v1.26 Manual

Hello,
In spite of following Python recommendations, I am getting ‘ValuErrors’ for Exercise 8.

Could you please suggest where exactly I am going wrong.

Thank you for your cooperation.
Sincerely,
Anurag

A. w, b = initialize_with_zeros(X_train.size) ;

Error Observed:
ValueError: shapes (1,28) and (4,7) not aligned: 28 (dim 1) != 4 (dim 0)

B. w, b = initialize_with_zeros(np.prod(X_train.shape))

Error Observed:
ValueError: shapes (1,28) and (4,7) not aligned: 28 (dim 1) != 4 (dim 0)

Hello,

Your codes for computation activation and cost are incorrect.

  1. For computation activation, hint given mentions to calculate activation
    Screenshot 1945-07-21 at 2.23.55 PM

which you have applied incorrectly.

  1. For cost, using np.transpose is causing shape mismatch. Review the below

Regards
DP

The argument for the initialize_with_zeros function should be the rows of X_train. Using X_train.shape grabs both, rows and columns. But you need only rows. How to do that?

Thanks a lot. Assignment has been submitted. Thanks.