Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Fit continuous targets with gradient descent and inspect residual behavior visually.
Gradient descent repeatedly moves parameters against the gradient to lower this loss.
m, b = 0.0, 0.0
for _ in range(steps):
dm = db = loss = 0.0
for x, y in data:
yhat = m*x + b
err = yhat - y
loss += err**2
dm += err*x
db += err
dm = 2*dm/len(data)
db = 2*db/len(data)
m -= lr*dm
b -= lr*db