Need clarification on Exercise 1- Two Layer Model For Loop

I have two fundamental question in Exercise 1-Two Layer Model

  1. We are using a for loop with iterations = 3,000. My code has passed all tests but the output only shows only few iterations. In addition, it only prints iterations =0 or iterations=1. I am not able to interpret how the for loop is getting executed
  2. Shouldn’t we be calculating the best cost, or lowest value, that is calculated in the for loop? Why are we only printing cost[0] and not the best cost
  1. We are NOT setting an iterations to 3,000. If you look at a test program carefully, it sets “num_iterations = 2”. If you refer “num_iterations =3000” in a parameter list for two_layer_model(), that is a default parameter just in case of “caller did not set this parameter”. It is not used in this test case. As the result, you get what you see in here.
  2. Printing cost is for your debugging purpose to ensure a) cost is properly calculated, b) “loop” is being executed, c) how cost is changing, etc. The cost is the result of a forward propagation. We optimize the network to reduce the cost by a backward propagation. So, we are keep monitoring the cost to see it reached to a global/local minimum. There are some optimization algorithms, but, basically, what we do is to stop iterations. You usually need hyperparameter tuning and callback setting to stop iterations in some cases. I think those are not covered by the first course of this specialization.

Hope this helps.