Hello,mentors could you please explain me how this print of last if function here?
I couldn’t understand what is copy.deepcopy() and paragraph from #save cost j for each iteration.
The % is the modulo operator.
The print() format specifies a text label, the variable name, and the format specifier for the display.
copy.deepcopy() creates new object and does real copying of original object to new one. Changing new copy.deepcopied object doesn’t affect original w_in.
j_history and p_history is initialized as empty list so items will be added then
so in the " save cost J at each iteration"
he saves the cost function and paramters (w,b) for every iteration in this lists that was initialized (j_history and p_history)
Hey @Mansi_singh and @Sayed_Mahmoud,
Welcome to the community. Thanks a lot @Sayed_Mahmoud for your response. I guess TMosh and Sayed have explained the major points in this, just to add a small point, this part of the code is storing the values of the cost function, weights and bias for every iteration, and every \frac{1}{10}^{th} interval of the total number of iterations, it is printing those values along with the values of the gradients. For instance, if we have say 127 iterations, it will print the values after every
(num_iters / 10) = 12.7
math.ceil(12.7) = 13
iterations = 0, 13, 26, 39 …
I hope this helps.
Regards,
Elemento
thank you @Elemento @TMosh @Sayed_Mahmoud.
@Elemento could please explain me what is the purpose to write :0.2e in j_history[1]:0.2e ? i couldn’t under stan what is 0.3e and 0.2e here?
Hey @Mansi_singh,
This is basically used for rounding off scientific notation in Python. You can read more about this on this Stack Overflow thread. I hope this helps.
Regards,
Elemento