← Lesson
Hyperparameters
Joeven
Run
Reset
Python loads on first run
xs = [1.0, 2.0, 3.0, 4.0] ys = [2.0, 4.0, 6.0, 8.0] def run(lr, steps): w = 0.0 for _ in range(steps): g = sum(2 * (w * x - y) * x for x, y in zip(xs, ys)) / len(xs) w = w - lr * g if w != w or abs(w) > 1e6: return "exploded" loss = sum((w * x - y) ** 2 for x, y in zip(xs, ys)) / len(xs) return "w=" + str(round(w, 3)) + " loss=" + str(round(loss, 4)) print("tiny lr ", run(0.0001, 25)) print("good lr ", run(0.02, 25)) print("huge lr ", run(1.0, 25))
Run to execute this in your browser. Nothing is sent to a server.