Why should we avoid modifying global w within gradient descent function in optional Lab C1_W3_Lab06_Gradient_Descent_Soln?

I am a bit confused about why should we avoid modifying global w within gradient descent function in optional Lab C1_W3_Lab06_Gradient_Descent_Soln?

Could someone please help explain this?

Hi @Nipun_Goyal, thank you for the question!

Specifically in our case of C1 W3 Lab06, we actually do not have to avoid it because we are only using the global w once and only once.

However, in general, it’s a good practice to do so when we want to make comparisons. For example, we have the learning rate parameter \alpha that we can set it to any values such as 0.01 or 0.001. if we want to know just how much difference they (and only they) bring to us, we want to keep all other initializations of the model the same, including the initialization of the weights.

So by making sure the global w unmodified, we can confidently say that any change in our experiment of different \alpha isn’t caused by a different initial w.

Cheers!