DLS 2 Week 1 Programming Assignment 1 initialization = "zeros" error

Hello,

I am a python neophyte. For zeros initialization, I chose “W” of size( l , l-1) and “b” as (l,1). is this correct? I am getting following error:

AssertionError: Not all tests were passed for initialize_parameters_zeros. Check your equations and avoid using global variables inside the function.

Please let me know. Thank you.

Hi @Paresh1,

Notice the function is receiving as argument layer_dims, supposedly an array with the layer’s dimensions. That means that you can get those values by accessing the array with the proper index (remember indexing in python starts at zero, so to access the first element you use layer_dims[0] and so on).

Look at the docstring of the function to see how can you get those values.

1 Like

Thank you, however, I am getting the following output

W1 =
b1 = [[0.]]
W2 = [[0.]
[0.]]
b2 = [[0.]
[0.]]
1 Tests passed
2 Tests failed

Fixed by @Paresh1.

The solution was already provided by @kampamocha.

Good luck with the rest of the course :slight_smile:

Thank you. I do have one more question: For Exercise 2, Initialize_parameters_random:

AssertionError: Not all tests were passed for initialize_parameters_random. Check your equations and avoid using global variables inside the function.

Please let me know. Thank you.

Fixed by @Paresh1.

Don’t hard-code dimensions unless the assignment explicitly tells you to do it :slight_smile:

Thank you, the problem is solved.

1 Like

Another question:

# YOUR CODE STARTS HERE
[Removed solution code]
# YOUR CODE ENDS HERE

AssertionError: Not all tests were passed for initialize_parameters_he. Check your equations and avoid using global variables inside the function.

Double check the formula:

image

Hint: there are two errors in your implementation of initialize_parameters_he.

YOUR CODE STARTS HERE

    parameters['W' + str(l)] = np.random.randn(layers_dims[l], layers_dims[l-1])*np.sqrt(2./layers_dims[l-1])*10
    parameters['b' + str(l)] = np.zeros((layers_dims[l], 1))        
    # YOUR CODE ENDS HERE

AssertionError: Not all tests were passed for initialize_parameters_he. Check your equations and avoid using global variables inside the function.

Problem solved. Thank you.

1 Like