Week 4 Programming assignment #1 AssertionError

AssertionError: Not all tests were passed for update_parameters. Check your equations and avoid using global variables inside the function.

I found a way to fix this by replacing “in-place” operators for the parameter updates. But I do not know why this will fail the grader?


W1 -= <update formula>


W1 = W1 - <update formula>

will fix the bug. why?

Hi Zachary,

Here, it’s asking you to subtract the change (in the form of learning rate)
from W1 (the weight matrix 1), which will provide the true result and then
only you would be able to get the desired result. Please put the variables

Also, note that learning rate comes as a deciding factor for getting the


The reason is that the in-place operators manage memory differently. If you use those, you end up modifying the global data that was passed in. Here’s a thread which explains this in detail.

1 Like

Hello @paulinpaloalto sir, where do we use these in-place moderators in machine and deep learning? Thanks in advance.

I’m not sure I understand the question. The “in place” operators are a python construct, but (as with every programming construct) you have to understand the full implications of their behavior in order to use them appropriately. In the particular “update parameters” example, as was explained on the thread I linked, all you have to do is do a copy within the local scope of the function in order to break the connection to the global data. Having done that, it is safe to use the “in place” operators. You did read the other thread that I linked above, I hope.

Yes @Paul sir, I understood it now.