C2_W3 Exercise 6

Hi, i did the exercise this way…and got the error msg at the bottom.

# Retrieve each parameter from the dictionary "parameters".
W1 = parameters["W1"]

# Retrieve each gradient from the dictionary "grads".
dW1 = grads["dW1"]

# Update rule for each parameter.
W1 = update_parameters(W1, dW1, learning_rate=1.2)

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

May i know what went wrong with my code? Many thanks

Please post a screen capture image of the entire error message. It should identify the function and line number where the error occurred.

Hi, this is the entire error msg thanks

I’m not a mentor for this course, so I don’t have access to the materials.

But it appears that at line 31 that you are calling the update_parameters() function from inside the update_parameters() function. That is a recursion, and it’s a bad thing.

Can any other mentor kindly take a look at my code and advise which part of my code is wrong? (the error message is copied above). Thank you

#Retrieve each parameter from the dictionary “parameters”.
W1 = parameters[“W1”]

#Retrieve each gradient from the dictionary “grads”.
dW1 = grads[“dW1”]

#Update rule for each parameter.
W1 = update_parameters(W1, dW1, learning_rate=1.2)

Is someone able to help? Thanks!

I know you asked for someone else to help you, but here’s my contribution anyway.

In update_parameters() I believe you are supposed to use the grads and learning rate to compute new values for W1, b2, W2, etc.

But what your code does at line 31 is recursively call the update_parameters() function again.

Thanks @TMosh ! From your comments, i managed to rectify line 31. Thank you!