W 2 A2 | Ex- 5 | Propagate : shapes not aligned

Hi,

For the ‘propagate_test’ function in the Logistic_Regression_with_a_Neural_Network_mindset notebook, I have the following code:

[code removed - moderator]

When I run this code, I get this error:

After looking at the numpy documentation, I understand that to compute the dot product of two matrices (a,b) and (c,d), b must be equal to c for it to work.

However, I followed the equation as specific in the assignment, so I don’t understand why the shapes are not the same. My sigmoid function passed the test and I calculated Z according to the equation.

I would appreciate some assistance regarding where I am going wrong here.

Thanks for taking the time to read this!

Cheers,
Laine

There are 2 bugs:

  1. When computing cost, you should divide by the batch size.
  2. Matrix multiplication is not commutative. So, please pay attention to order of the operands when computing dW.