C1_W2 error at Cost calculation

I am getting the wrong result and some error at the compute cost with initial parameters stage
What can be the cause?

Hi @Szpak_Marcin , Have you divide the total cost you got by (2 * m ) at end?
Have you implemented following steps correctly?

  • Iterate over the training examples, and for each example, compute:

    • The prediction of the model for that example
    f_{wb}(x^{(i)}) = wx^{(i)} + b
    • The cost for that example
cost^{(i)} = (f_{wb} - y^{(i)})^2
  • Return the total cost over all examples
J(\mathbf{w},b) = \frac{1}{2m} \sum\limits_{i = 0}^{m-1} cost^{(i)}

Hi @ritik5 , thank you for your comments, I use the following formulas, which I think are in line with what you present:

Hi @Szpak_Marcin Sharing code on discussion form is not allowed, so you should delete the code.
Use (1 / (2 *m)) instead of (1 / 2 * m) when calculating total_cost,
Because 1 / 2 * m = 0.5 * m which is not equal to 1 / (2 * m).

@ritik5 thanks a lot, stupid math error, it works now :smile: