Assignment: strange error in Exercise 6, update params with Adam

My code produces the expected results for everything except W1 which is slightly off. Oddly, the results for W2 are correct even though the code is the same – just a different iteration through the same loop. I am getting error messages for
"wrong type of “v_corrected[’{key}’]. Expected np.ndarray” and
“Wrong shape for v_corrected[’{key}’]. The update must keep the dimensions of v inputs”

Yet, adding print statements reveals that ALL keys of v_corrected are of type np.ndarray
and ALL keys of v_corrected have the same dimensions as v.

I am also getting an error message saying that v_corrected[‘dW1’] has incorrect values.

The two relevant lines of code are as follows.

v[ "dW" + str(l) ] = beta1 * v[ "dW" + str(l) ] + (1-beta1) * grads[ "dW" + str(l) ]
v_corrected[ "dW" + str(l) ] = v[ "dW" + str(l) ] / (1 - math.pow(beta1,l) )

What on earth could be going on? Why does this work for iteration l =2 but not for iteration l = 1?

Hi @GCRhoads, take a look at the formula of v_corrected, I spot an error on your implementation of the beta1 part, maybe that is causing the problem.

Also, please edit your post to not show your code explicitly.

Hope that helps.

I see the error now.

I can’t find an edit button/option for editing my previous message. How can I edit my original message?

You should see a pencil icon right below your post, like this:

Should, but I see no such icon below my original post. None shows up when I click on the three dots either. (strangely, I do see the pencil icon for my second post!)