PythiloLesson 9 of 12 · progress kept in this browser

Mini-batch SGD

Each batch updates the parameter before the next batch is evaluated. Average within a batch, including a shorter final batch.

xs = [1, 2, 3, 4, 5]
for start in range(0, len(xs), 2):
    print(xs[start:start+2])
Your task

epoch(xs, ys, w, lr, batch_size) returns the new scalar w after one ordered epoch minimizing mean squared error for y=w*x, with no intercept. Use gradient 2*mean((w*x-y)*x). batch_size > 0.