W3_A1_Compute Cost


Whats the error here? I used the same logic in week 1 assignment it was working .

You have made one of the common mistakes in this section: you took the sample code they gave you as the complete solution. It’s not. They even told you that in the instructions, although perhaps they were a bit too subtle about it. Compare that code to the mathematical formula for the cost shown above and ask yourself two questions:

  1. Why is there only one term? What happened to the Y = 0 term?
  2. What happened to the factor of \frac {1}{m}?

Note that a difference in the third decimal place is not a rounding error: it’s a real error. We’re doing 64 bit floating point, so rounding errors are in the 16th decimal place or thereabouts. Even in 32 bit floats, a rounding error would be 10^{-7} in the mantissa.

Oh Yes I got it . Thanks!