For the exercise to run, why - when calculating the gradients - did I have to redefine f_wb, given that earlier in the exercise (computing the cost, exercise 1), I already had defined the function f_wb?
Calculating the gradients:
for i in range (m):
f_wb = w * x[i] + b
dj_dw_i = (f_wb - y[i]) * x[i]
dj_db_i = (f_wb - y[i])
dj_dw = dj_dw + dj_dw_i
dj_db = dj_db + dj_db_i
Any variable that is defined outside of a function is a global. So anything created in the main body of the notebook is a global.
Variables defined inside a function are local.
So if you are working inside a function, and you’re using a variable that wasn’t defined inside the function or passed to it as a parameter, then it’s likely a global variable.
The first thing to check is whether your code is using all of the variables that are passed as parameters.