WRITE · TRACE · UNDERSTAND
Mini-batch SGD
Each batch updates the parameter before the next batch is evaluated.
Your experiment
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.
Python runs in your browser. Your draft stays on this device.
What to look for
Each batch updates the parameter before the next batch is evaluated. Average within a batch, including a shorter final batch.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.