Week 3 Programming Assignment Exercise 7 subtract AND operator -= update parameter

Hi, for the General gradient descent rule, may I know why must we do

W1 = W1 - learning_rate * dW1

when I try with

W1 -= (learning_rate * dW1)

it returns me with an error of

Error: Wrong output for variable W1

as far as I know, the 2 lines above have the same meaning, but in the programming assignment I got an error when using -= . Can you clarify on this matter or i might have missed something? thank you so much.

It turns out that those two lines result in the same output value, but they are not equivalent in terms of how they handle memory. Here’s a thread which explains why -= does not work for this particular test case unless you take some additional action.

I understand now, thank you so much for it!!!

1 Like