DLS Course 2 Week 2 Programming Assignment Exrercise 1


I am getting following error:
ValueError: operands could not be broadcast together with shapes (2,3) (3,3)

code: parameters[“W” + str(l)] = parameters[“W1”] - learning_rategrads[“dW1”]
parameters[“b” + str(l)] = parameters[“b1”] - learning_rate

Please let me know. Thank you.

The shape of the gradient of an object should always be the same shape as the object. So why is that not happening in your code? Which is the correct shape: is it 2 x 3 or 3 x 3?

Note that it’s a bit worrying that you show code that has hard-coded the keys for “dW1” and “db1” and so forth. Why are you not using the layer number as a variable and using the "W" + str(l) or "dW" + str(l) method throughout?

It works now. Thank you.