Error in exercise 5 week 2 initialize_Adam

hi. why this could is not correct?
v[“dW” + str(l+1)] = np.zeros_like(parameters[“W” + str(l+1)])
v[“db” + str(l+1)] = np.zeros_like(parameters[“b” + str(l+1)])
s[“dW” + str(l+1)] = np.zeros_like(parameters[“W” + str(l+1)])
s[“db” + str(l+1)] = np.zeros_like(parameters[“b” + str(l+1)])

I get this error:
NameError Traceback (most recent call last)
in
1 parameters = initialize_adam_test_case()
2
----> 3 v, s = initialize_adam(parameters)
4 print(“v["dW1"] = \n” + str(v[“dW1”]))
5 print(“v["db1"] = \n” + str(v[“db1”]))

NameError: name ‘initialize_adam’ is not defined

Please run the cell containing def initialize_adam(parameters) : before running the cell that tests it.

thanks a lot for your reply. but it did not work. there is also another error under the def initialize_adam(parameters) :

File “”, line 36
v[“dW” + str(l+1)] = np.zeros_like(parameters[“W” + str(l+1)])
^
IndentationError: expected an indented block

You apparently have a python syntax error in your code, which is why that function is not defined. Indentation is part of the syntax of python. My guess is that the previous line is a “for” statement. In python, the way you specify the body of a “for” loop is by indenting the lines of code to be executed in each iteration.

This is not a beginning python course and that is a pretty fundamental part of python. If you are not familiar with how indentation is used in python, you might want to spend some time on an “intro to python” course or some tutorials. Try googling “python indentation” and you’ll find plenty of useful tutorials.

1 Like

I am getting the following error. How do i access the test code, and why would the test algo be undefined?


NameError Traceback (most recent call last)
in
----> 1 parameters = initialize_adam_test_case()
2
3 v, s = initialize_adam(parameters)
4 print(“v["dW1"] = \n” + str(v[“dW1”]))
5 print(“v["db1"] = \n” + str(v[“db1”]))

NameError: name ‘initialize_adam_test_case’ is not defined

That probably simply means you haven’t run the previous cells in the notebook. You need to do that everytime you reopen the notebook.

The tests are in public_tests.py, which you can examine by clicking “File -> Open” and having a look around.