Skip to content

Instantly share code, notes, and snippets.

@josetapadas
Created October 27, 2019 15:05
Show Gist options
  • Save josetapadas/19b3fda468196bfed34be690ab155f83 to your computer and use it in GitHub Desktop.
Save josetapadas/19b3fda468196bfed34be690ab155f83 to your computer and use it in GitHub Desktop.
# initial values
b = 30
m = 3
db = 1
dm = 1
limit = 0.00001
learning_rate = 0.001
step_size_b = -3
step_size_m = -3
i = 0
while abs(step_size_m) > limit:
i += 1
step_size_b = db * learning_rate
b = b - step_size_b
db = (1/4) * ((-2*(50-(m*5+b))-2*(72-(m*10+b))-2*(76-(m*15+b))-2*(90-(m*20+b))))
print("******** iteration: ", i)
print("b", b)
print("db", db)
print("step_size_b", step_size_b)
step_size_m = dm * learning_rate
m = m - step_size_m
dm = (1/4) * (-10*(50-(m*5+b))-20*(72-(m*10+b))-30*(76-(m*15+b))-40*(90-(m*20+b)))
print("m", m)
print("dm", dm)
print("step_size_m", step_size_m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment