Practice lab 1

I have Query in implementation of following lines of code in the practice lab 1 .
What is the purpose of following “IF” statements?
if i<100000: # prevent resource exhaustion
cost = cost_function(x, y, w, b)

    # Print cost every at intervals 10 times or as many iterations if < 10
    if i% math.ceil(num_iters/10) == 0:

Here is the link to the code

Thanks in advance.

1 Like

It saves the current value of the cost after every 10th calculation, so it can late be plotted as the cost history.

The reason for the limitation on 100000 iterations is to prevent the J_history array from consuming too much memory, if you let it run for a very long time.

1 Like