Week1 Lab 5 -why we have set value for DJ-dw and dj_dw both as 0

def compute_gradient(x, y, w, b):

# Number of training examples
m = x.shape[0]    
dj_dw = 0
dj_db = 0

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_db += dj_db_i
    dj_dw += dj_dw_i 
dj_dw = dj_dw / m 
dj_db = dj_db / m 
    
return dj_dw, dj_db

here in the above code why we have set value for DJ-dw and dj_dw both as 0.

1 Like

just to initialize them and use the
to can be use later in
dj_db += dj_db_i
dj_dw += dj_dw_i
as this equal to dj_db = dj_db + dj_db_i