grouped_instances = group_by_count(instances, self._batch_size, None)
// The last group might have not been full, so we check if any of the instances
// are None, which is how group_by_count pads non-complete batches.
grouped_instances[-1] = [instance for instance in grouped_instances[-1] if instance is not None]
return (Batch(batch) for batch in grouped_instances)
@classmethod
def from_params(cls, params: Params) -> "BasicIterator":
After Change
iterator = iter(instance_list)
// Then break each memory-sized list into batches.
for batch_instances in lazy_groups_of(iterator, self._batch_size):
yield Batch(batch_instances)
@classmethod
def from_params(cls, params: Params) -> "BasicIterator":
batch_size = params.pop_int("batch_size", 32)