make_batch
make_batch(data: Union[Iterable, Generator], batch_size: int) -> Generator[List, None, None]
-
Description: This function is used to convert data into batched data.
-
Parameters:
- data (
Union[Iterable, Generator]
): The data generator. - batch_size (
int
): The size of batches.
- data (
-
Returns:
- Generator[List, None, None]: A generator for batched data.
-
Example:
import docsaidkit as D
data = range(10)
batch_size = 3
batched_data = D.make_batch(data, batch_size)
for batch in batched_data:
print(batch)
# >>> [0, 1, 2]
# >>> [3, 4, 5]
# >>> [6, 7, 8]
# >>> [9]