Shuffle matching feature and label arrays once, then yield consecutive mini-batches. Use np.random.default_rng(seed) to shuffle one index array and apply it to both inputs. Each yield must be a tuple (X_batch, y_batch) containing NumPy arrays. If drop_last is true, omit a final batch smaller than batch_size.
Input: X = [0, 1, 2, 3, 4, 5, 6], y = [0, 1, 2, 3, 4, 5, 6], batch_size = 3, seed = 42, drop_last = False
Output: [[[3, 2, 6], [3, 2, 6]], [[4, 1, 5], [4, 1, 5]], [[0], [0]]]
Explanation: One seeded permutation is sliced into batches of three, with the final single sample retained.
Input: X = [0, 1, 2, 3, 4, 5, 6], y = [0, 1, 2, 3, 4, 5, 6], batch_size = 3, seed = 42, drop_last = True
Output: [[[3, 2, 6], [3, 2, 6]], [[4, 1, 5], [4, 1, 5]]]
Shuffle np.arange(len(X)) with np.random.default_rng(seed).
Slice the shuffled indices inside range(0, len(indices), batch_size).
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Accepts: number
Shuffle matching feature and label arrays once, then yield consecutive mini-batches. Use np.random.default_rng(seed) to shuffle one index array and apply it to both inputs. Each yield must be a tuple (X_batch, y_batch) containing NumPy arrays. If drop_last is true, omit a final batch smaller than batch_size.
Input: X = [0, 1, 2, 3, 4, 5, 6], y = [0, 1, 2, 3, 4, 5, 6], batch_size = 3, seed = 42, drop_last = False
Output: [[[3, 2, 6], [3, 2, 6]], [[4, 1, 5], [4, 1, 5]], [[0], [0]]]
Explanation: One seeded permutation is sliced into batches of three, with the final single sample retained.
Input: X = [0, 1, 2, 3, 4, 5, 6], y = [0, 1, 2, 3, 4, 5, 6], batch_size = 3, seed = 42, drop_last = True
Output: [[[3, 2, 6], [3, 2, 6]], [[4, 1, 5], [4, 1, 5]]]
Shuffle np.arange(len(X)) with np.random.default_rng(seed).
Slice the shuffled indices inside range(0, len(indices), batch_size).
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Accepts: number