Typo in c1w5 notebook?


Regarding def ‘gradient_descent’ in c1w5 jupyter notebook, there seem to be two redundant lines. Can I ask their functionality and ask if this is a typo?

  1. w = copy.deepcopy(w_in) #deep copy
  2. w = w_in #shallow copy
    Additionally, num_iter input in gradient_descent is not used inside(6/30 EST).

Hello @MJ_Shin!

Thank you for sharing that! I suppose you are referring to course 1 week 2 practice lab section 2.6.

First, yes, the line w = w_in is not needed. w = copy.deepcopy(w_in) will make a new copy of the data of w_in and put it into w. In contrast, w = w_in does not make a new copy. So in the later case, modifying w will also modify w_in, which is not always wanted. So, it’s better to use w = copy.deepcopy(w_in) when you want to keep the original copy (w_in) untouched, or as a backup.

Second, num_iter is used in the line of the for statement. Please take a look at that.


Thank you for your reply. I made a mistake of understanding a certain constant as the num_iter.

You are welcome, Myong Jong! Let us know if you have other questions!