chemicalchecker.core.signature_data.RandomBatchSampler
- class RandomBatchSampler(dataset, batch_size)[source]
Bases:
Sampler
Sampling class to create random sequential batches of a dataset.
E.g. if data is [1,2,3,4] with bs=2. Then first batch, [[1,2], [3,4]] then shuffle batches -> [[3,4],[1,2]] This is useful for cases when you are interested in ‘weak shuffling’ https://towardsdatascience.com/ reading-h5-files-faster-with-pytorch-datasets-3ff86938cc
- Parameters:
dataset (torch.utils.data.Dataset) – dataset you want to batch
batch_size (int) – batch size
- Returns:
generator object of shuffled batch indices
Methods