DLS C2 W1 gradient_checking

I have been busting my head for a while. but I can figure out the meaning of this error:


As you can see at the top of the image, I am printing out temp and it seems okay… is it not?

That error is talking about the assignment to the LHS of that assignment statement. You are assigning the return value of forward_propagation_n to a single element of an array, right? But if you look at the definition of forward_propagation_n, it returns two return values: the cost (which is what we want) is the first return value. So you need to specify the LHS as a list with two elements. They showed you how to do that in the comments for that section, but you must have missed that or not understood the implications of saying:

J_plus[i], _ = function()

That says that you are expecting two return values, but you don’t care about the second one. If you say this instead:

J_plus[i] = function()

Then python tries to “help you out” by converting the two return values into a single 2-tuple and then assign that to your variable. That’s what happened and why it threw that error.

2 Likes

Awesome! this was the issue!. Thanks <3

1 Like