C1_Week2_Programming Assignment Error related to dimensions

I am getting the error below when running the evaluation cell below the cell where propagate function is created. Its a error related to the dimentions, but not sure what the issue is… Any help will be appreciated:

Hi Balaji,

The error message states, that the dimension of the two shapes that are given should be the same. They should either be (1,1) or (3,3) if I understand correctly.

Hope that helps


To implement the mathematical formula for the cost in code, you have (at least) two choices for vectorized methods:

  1. Use np.multiply or * to multiply the corresponding elements and then use np.sum to add up the products.
  2. You can use np.dot to do both the multiply and the sum in one operation, but if you do that then you need a transpose in order for the rules of normal “dot product” style matrix multiplication to work. The “inner dimensions” need to agree, right? 1 x 3 dotted with 3 x 1 will give you a 1 x 1 or scalar output, which is what is required here.

Thanks a ton. That helped

Thank you for your response.!

You are welcome :smiley:

Happy that I could help.