1
0
This commit is contained in:
2024-06-03 09:38:49 +08:00
parent e03a7de8f9
commit 2d1957b8c7
7 changed files with 261 additions and 103 deletions

View File

@@ -19,8 +19,8 @@ def step_gradient(b_current, w_current, points, learningRate):
for i in range(len(points)):
x = points[i][0]
y = points[i][1]
b_gradient += -(2 / N) * (y - (w_current * x + b_current) + b_current)
w_gradient += -(2 / N) * x * (y - (w_current * x + b_current + b_current))
b_gradient += -(2 / N) * (y - (w_current * x + b_current))
w_gradient += -(2 / N) * x * (y - (w_current * x + b_current))
new_b = b_current - (learningRate * b_gradient)
new_w = w_current - (learningRate * w_gradient)
return [new_b, new_w]