MLS week 2 Lab Gradient descent

Hello @zbukhari,

The error says that your function cannot compute the result correctly, and that’s because the function isn’t implemented correctly.

Since debugging your code is part of your assignment, I can suggest you 2 methods for debugging, and I hope they will be helpful for the rest of assignments in this specialization. Both methods require your understanding of the exercise.

Also, sharing assignment code isn’t allowed, please remove it and only share the screenshot with the error message.

Method 1: Read the code

  1. These are what we want to implement:
    Screenshot from 2022-11-03 18-25-38

  2. If we look at the first equation, it has 3 parts:

    1. \frac{\partial J(w,b)}{\partial b}^{(i)}
    2. \sum\limits_{i = 0}^{m-1}
    3. \frac{1}{m}
  3. The idea is we calculate (2.1) for each sample, then sum over all samples (2.2), and then divide the resulting sum by m once (2.3)

  4. Following this idea, you read your code again to see if your code is doing exactly that.

Method 2: Examine the progress of your code

  1. Add printing lines in between your codes to print all intermediate variables you have assigned values to, for example,
    Screenshot from 2022-11-02 18-59-29
    Source: General code debugging tips

  2. Run your function with some simple inputs. For detailed instructions, please check this post out.

  3. You check if the printed outputs are up to your expectation, if one number is unexpected, then there is a problem.