Skip to content

Instantly share code, notes, and snippets.

View mmsamiei's full-sized avatar
🤔
create and develop a framework for life ...

Mohammad Mahdi Samiei mmsamiei

🤔
create and develop a framework for life ...
View GitHub Profile
from torchtext.data import BucketIterator, interleave_keys
batch_size = 32
def batch_size_fn(new, count, sofar):
"Keep augmenting batch and calculate total number of tokens + padding."
# (new example to add, current effective batch size, current count of examples in the batch)
# when returned value meets batch_size (effective, innate effective batch_size
# defined as global bala bala) then wraper create a batch