Hi, in the screenshot below from the graded lab on Linear Regression for Course 1 Week 2, why do we need the if statements in the pink and blue boxes? I also don’t really understand what the if-statement in the blue box means. What would happen if we didn’t include the two if-statements in the pink and blue boxes?
Thank you!
Hi @Sreeyutha_Ratala
The if statements are not required from a math view but from a computer resources view. One of the tasks that this function does is create a history of the J’s and the w’s as well as print().
The if statement in the pink box stops recording the J’s after 100000 iterations and the if statement in the blue appends every 10th iteration of w and prints to the screen.
Should the if statements not be in place, when the function is called with a really large number of iterations and the notebook might run out of computer memory and crash.
Hope this helps!
Yep, that makes much more sense now. Thank you!