quantlab.model.torch_data.batch_loader#

quantlab.model.torch_data.batch_loader(dataset, sampler, *, num_workers=0, pin_memory=False)[source]#

A DataLoader that hands each batch of positions to dataset[positions] whole.

The dataset gathers the batch itself (as SymbolSequenceDataset does), so nothing is split into items and collated back: the loader runs with batch_size=None over sampler’s batches.

Examples

>>> loader = batch_loader(dataset, IndexBatches(len(dataset), 3))
>>> tuple(next(iter(loader)).x.shape)
(3, 2, 1)