Course 1 Week 4 Exercise 2 - initialize_parameters_deep

Error: Wrong output for variable W1.
Error: Wrong output for variable W2.

I followed the same pattern

 parameters["W" + str(L)] = np.random.randn(layer_dims[1], layer_dims[0]) * 0.01

just used (l,l-1) for shape W
But don’t know where I am wrong

It is a mistake to “hand import” your solutions from the Step by Step exercise. It turns out they supply their own implementations and they end up using a different more sophisticated initialization algorithm for the “deep” case. It just turns out that the simplistic version they had us build in the first exercise in Week 4 just doesn’t work very well in this case. We’ll learn more about that in Course 2 of this series, but there’s too much other new material here in Course 1 to get into that.

I tried to do according to for loop. Could you please assist further. I know there is a small mistake to handle…

Please say more about which problem you are working on? Are you doing the “Step by Step” exercise? Or the “Application” exercise? And which function?

Step by Step exercise.

initialize_parameters_deep Function

just use “np.random.rand(layer_dims[l],layer_dims[l-1]) * 0.01” in for loop

but still getting wrong W1 & W2 values

You are using the wrong random function. They literally wrote the code for you in the instructions. It uses “randn”, not “rand”, right?

2 Likes

thanks :), silly mistake.

I am not getting whats my error please help @paulinpaloalto

{moderator edit - solution code removed}

There is a missing close paren on the previous line. I did not have this problem, so you must have accidentally deleted that close parenthesis.

Ohh yes I see again a silly mistake …Thank you for your fast reply!!!