For Exercise 7 - update_parameters, I use the general equation provided to calculate W1 from dW1 and learning rate. However my code fails the test case due to wrong W1. With some debugging, when I print:
print(f"{W1.shape},{dW1.shape}")
I get
(1,4),(4,2)
I thought W1 should have the same shape as dW1, did I miss something?
Your understanding of shapes is correct. W1.shape
is the same as dW1.shape
.
That said, there’s no need for any equation to arrive at W1
.
W1
is stored in one of the dictionaries that are passed on as function parameters to update_parameters
.
There must be something wrong with your update formulas. Notice that in the particular test case here W1 is 4 x 2, but W2 is 1 x 4. So your dW1 is the correct shape, but then how did W1 end up the wrong shape? Hmmmmm. Sounds like a classic “copy/paste” error to me …
Mystery solved. I had a W2 = W1 = “deep copy of W2 params” further up in the code . The wonders of leaving for a while and coming back to look at your code…