promptdojo_

Loss, forward, backward, step — step 6 of 7

Write train(data, lr, epochs) implementing the full four-beat loop for y = w*x + b (both gradients, both updates, starting from 0, 0) and returning (w, b). Train 200 epochs at lr=0.02 on the noisy y ≈ 3x + 1 data, then print f"w={w:.2f} b={b:.2f} loss={loss:.4f}" with the final MSE.

full-screen editor opens — close anytime to keep reading.