Mini-Batch Processing
Mini-Batch Processing
When a dataset is too large to fit in memory, you process it in mini-batches: fixed-size contiguous chunks. This is also the standard pattern for SGD-based training.
Given an array X and a batch_size, partition X into consecutive non-overlapping batches. The last batch may be smaller than batch_size if n is not divisible by batch_size — include it anyway.
Example: X = [1, 2, 3, 4, 5], batch_size = 2
Batch 0: [1, 2] Batch 1: [3, 4] Batch 2: [5] ← smaller final batch, still included
Your task:
Implement make_batches(X, batch_size) that returns a list of NumPy arrays, one per batch.
Example Tests
5 elements with batch_size=2 produces 3 batches
Input: {"X":[1,2,3,4,5],"batch_size":2}
Expected: 3
First batch contains first two elements
Input: {"X":[10,20,30,40],"batch_size":2}
Expected: [10,20]
Evenly divisible: no partial batch at end
Input: {"X":[1,2,3,4,5,6],"batch_size":3}
Expected: 2