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])From arithmetic to an experiment
Each batch updates the parameter before the next batch is evaluated. Average within a batch, including a shorter final batch. The trace reads the local variables of your function as it executes. Change one input or parameter, predict the result, then run the checks again. A small deterministic example makes arithmetic mistakes easier to locate than a long training run. State the shape and meaning of the returned value before coding. Keep preprocessing, evaluation and model updates in their proper order, and examine the boundary case in each check. The companion lab lets you replay intermediate values while the same algorithm runs.
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.
The explanation opens here once every check passes.