Splits X into equal sized chunks.
(X, batch_size=64)
| 8 | |
| 9 | |
| 10 | def batch_iterator(X, batch_size=64): |
| 11 | """Splits X into equal sized chunks.""" |
| 12 | n_samples = X.shape[0] |
| 13 | n_batches = n_samples // batch_size |
| 14 | batch_end = 0 |
| 15 | |
| 16 | for b in range(n_batches): |
| 17 | batch_begin = b * batch_size |
| 18 | batch_end = batch_begin + batch_size |
| 19 | |
| 20 | X_batch = X[batch_begin:batch_end] |
| 21 | |
| 22 | yield X_batch |
| 23 | |
| 24 | if n_batches * batch_size < n_samples: |
| 25 | yield X[batch_end:] |
no outgoing calls
no test coverage detected