Course 2, Week 2, Assignment Optimization_methods

Hi, dear colleagues
I have problems with the cell called
“# GRADED FUNCTION: update_parameters_with_momentum”
To my understanding the formula I have to implement is this:

V_dW(i) = beta * V_dW(i-1) + (1-beta) * dW(i)

Consequently for i = 1 I have the problem, that there is a V_dW(i=0) needed which doesn’t exist.
So to my view there should be a V_dW(i=0) provided. But it wasn’t.
Please explain …
Thanks a lot!
Kind regards,
Goetz

Hi @goetz,

Not sure why you are doing i-1 here, that’s no where mentioned in the formula provided in the markdown.

Hi, how can I “reset” my notebook completely?

Read this guide to get a clean copy of your notebook.

Also note that there may be a python syntax issue there. If you use parens, it thinks you are making a function call. If what you really meant was to index a list, array or dictionary, then you must use square brackets, right?

If you say dW(0) it thinks you are calling a function dW and passing it the argument 0. If dW is a dictionary or a numpy array, that will not end well. :scream_cat:

1 Like

This is not the syntax. I just went “with the flow” with how the learner used it as the expression of the formula.

Oh, sorry, I meant that reply to go to the original author of the thread and not to you. :nerd_face:

Hi ,
yes - that was only my text here in my post … My code is

v[“dW” + str(l)] = beta*v[“dW” + str(l)] + (1-beta)*parameters[‘W’ + str(l)]
Best,
Götz

Hi ,
in the markdown text above there is a formula corresponding to this code:

v[“dW” + str(l)] = beta*v[“dW” + str(l)] + (1-beta)*parameters[‘W’ + str(l)]

But in my opinion this line is wrong, it show say:
v[“dW” + str(l)] = beta*v[“dW” + str(l-1)] + (1-beta)*parameters[‘W’ + str(l)]

But then at l = 1(first loop) I obviously need an initiated vdW[0] - which I don’t have … I don’t understand that …
Best,
Götz