Created
March 26, 2020 10:18
-
-
Save wiccy46/6c3ef75e60b0e2e1ecb01b8f6729b0b8 to your computer and use it in GitHub Desktop.
[batch] Batch generator #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def batch_generator(items, batch_size): | |
batch = [] | |
i = 0 | |
for item in items: | |
batch.append(item) | |
if len(batch) == batch_size: | |
yield batch | |
batch = [] | |
yield batch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment