C1_W1_Lab05_Gradient_Descent_num_iters

Hello guys I have a problem with this value num_iters
why num_iters has no initial value ?
can someone help me please?

Hello @Mehrdad_Rahmanigermi,

Please check the following screenshot out for the value of num_iters

This is not a training parameter so it will not be changed by the gradient descent. This is used to constrain the number of gradient descent to be done so that it will not run forever.

Raymond

thanks a lot Raymond
would you please explain this code too, I can’t understand where these numbers came from.

The numbers come from within the loop. For example, i is from for i in range(num_iters). I suggest you to copy the variable that you don’t know where it is from, press “Ctrl+F”, paste the variable in the search field, search it, and you will see where it is from.

thanks again but I don’t understand {J_history[-1]:0.2e} .

Thank you for being specific!

J_history is a list object and you can see that it keeps appending new values to the list over the loops, so you can expect the list to be growing and including more and more values.

J_history[-1] takes out the last value and formatted as “0.2e”. “e” is a format specifier and you can check out the explanation here. If you want to know what the “2” means there, change it to 1 or 5 or 9 and run the code again to see what will happen.

i’m appreciated for your complete answer.

1 Like

You are welcome Mehrdad!