In the C1_W3_Lab06 the gradient is calculated using two for loops, as per my understanding the first for loop (for i in range m) here w is multiplied with the first feature of x, and err is calculated using that first feature, but when calculating loss that same err is multiplied to the second feature of same row of X. shouldn’t the multiplication be done with err calculated from the second feature
There are two features in the lab example.
The second for-loop iterates over the features.
for j in range(n):
A gradient is calculated for each feature.
Is the err term calculated for individual feature? or the same err term is multiplied with two features?
What “err” term are you referring to specifically?
for i in range(m):
f_wb_i = sigmoid(np.dot(X[i],w) + b) #(n,)(n,)=scalar
err_i = f_wb_i - y[i] #scalar
for j in range(n):
dj_dw[j] = dj_dw[j] + err_i * X[i,j] #scalar
dj_db = dj_db + err_i
dj_dw = dj_dw/m #(n,)
dj_db = dj_db/m #scalar
in this code , isn’t the err_i calculated for only for the ith term of X? and tha err is then multiplied with both the feature of first row to calculate the dj_dw
My question is shouldn’t the err_i term calculated indivisually for each feature?
Please edit your message so that your code is enclosed in the “pre-formatted tag”, so that the indention is preserved.
I can’t answer what your code does without seeing the indentation.