Created
August 1, 2019 21:47
-
-
Save shubhamagarwal92/655a4d86d5c945e6c8b4be5293c8db20 to your computer and use it in GitHub Desktop.
Get batch size chunks from list
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
# Yield successive n-sized | |
# chunks from l. | |
def divide_chunks(l, n): | |
# looping till length l | |
for i in range(0, len(l), n): | |
yield l[i:i + n] | |
test_list = list(range(100)) | |
batch_size = 10 | |
for batch in divide_chunks(test_list, batch_size): | |
print(batch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment