Accessing values in a dictionary requires brackets [], not parentheses () (see this answer. From the code you’ve given us, it looks like grads("db" + str(l+1)) needs to be changed to grads["db" + str(l+1)] to fix your error.
A few notes on style:
- The character lowercase ‘
l‘ shouldn’t be used as a variable name in order to avoid confusion with capitalIor the number1. - The
a = a - bpattern can be replaced witha -= b. - Since
str(l+1)is called so frequently, you might consider saving that string as a variable.
solved Updating dictionary in python, during gradient descent