BatchSampler#
- class braintools.trainer.BatchSampler(sampler, batch_size, drop_last=False)#
Wraps a sampler to yield batches of indices.
- Parameters:
Examples
>>> base_sampler = SequentialSampler(dataset) >>> batch_sampler = BatchSampler(base_sampler, batch_size=32) >>> for batch_indices in batch_sampler: ... print(len(batch_indices)) # 32 (or less for last batch)