Error with the code in Chemical Segregation Challenge

Here is the link to my code: https://drive.google.com/file/d/17Dcic8po7CFUo5ROQpKHLa1BuR2RN2Fd/view?usp=sharing

Can you please review it? Please, let me know what I am doing wrong.

Hi @saurabh48782,
Replace these two lines:

w = w + learning_rate*grad_w
b = b + learning_rate*grad_b

with this:

w += learning_rate*grad_w
b += learning_rate*grad_b

This will resolve your issue. The original syntax failed to update the weights.

what is the reason, both pieces of code are expected to do same thing right?

The reason is pretty python specific. Some operators like “+=” modify the variables in-place, and hence, the original W array passed to the function is updated.
But, when you use it like this “W = W+x”, you are actually creating a new numpy array and assigning it to the local variable W. This fails to update the original array W passed to the function.
In the future, always use operators like “+=”, “-=”, etc. when the purpose is to modify the original array passed to the function.