C1_W1_Lab04_Gradient_Descent_Soln

Can somebody explain to me, the math behind the #Print cost every at intervals 10 times or as many iterations if < 10;

Why is for example f"Iteration {i:4}: Cost {J_history[-1]:0.2e what does the 4 and the 0.2 e mean?
f"dj_dw: {dj_dw: 0.3e}, dj_db: {dj_db: 0.3e} → same here, from where do the numbers come from and what do they mean?

And again: print(f"(w,b) found by gradient descent: ({w_final:8.4f},{b_final:8.4f})") → What does the 8.4 mean.

I hope you got my question and Thank you already in Advance for the Help. Its really appreciated. :blush:

2 Likes

Hi @MHae ,

These are print statements using the Python f- strings format. Here is a tutorial about how to use this kind of formatting statements.

1 Like

@Kic

Ok Thank you. Some is clarified, but I still dont understand, why you use sometimes 0.2 or 0.3 or 8.4?

Are that just example values, to show python how the output should look?

Hi @MHae

Within that link I gave you, there is a link for more information on string formatting, Here is the link again, it explains what those fields are.

1 Like

Hi @MHae , this is the way to format the output. To have a good idea how it works, you can just detele the values after the : and run the cell to see what happens. Then you will understand why the instructor uses string formatting to display the values.
Keep learning!

1 Like