DLS Course 2 Week2 Ex3 Error

Hi,
The below is my code :

{moderator edit - solution code removed}

I dont know what triggers the error, Can someone pls help?

You are using np.zeros incorrectly: it takes a “tuple” as the argument, right? What shape are your results? Here’s what the correct output looks like:

v["dW1"] =
[[0. 0. 0.]
 [0. 0. 0.]]
v["db1"] =
[[0.]
 [0.]]
v["dW2"] =
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]
v["db2"] =
[[0.]
 [0.]
 [0.]]
 All tests passed.

Yours end up being 1D arrays, which is not what is expected here. They also don’t end up with the correct number of elements.

1 Like

HI ,

Here is how my output looks like:

Yep I got what I was doing wrong, I was not including the shape of the parameters inside np.zeros()

RIght! Clearly “len()” is not what you want in that case:

A = np.random.randn(3,5)
print(f"A.shape = {A.shape}")
print(f"len(A) = {len(A)}")
A.shape = (3, 5) 
len(A) = 3
1 Like