promptdojo_

Write gradient_descent(w, x, y, lr, steps) that runs steps descent updates on the model pred = w * x and returns the final w, rounded to 2 decimals. Each step: pred = w*x, grad = 2*(pred-y)*x, w = w - lr*grad.

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