dataset.data_prep.Indice_Sampler

class dataset.data_prep.Indice_Sampler(mask)[source]

Bases: Sampler

This is a sampler for Pytorch DataLoader in which it will sample from the Dataset with indices of mask.

Parameters

mask: torch.tensor

The indices of the samples.

Example

>>> from torch.utils.data import DataLoader
>>> brain = Brain_Large()
>>> dataloader = torch.utils.data.DataLoader(brain,
                                             batch_size=64,
                                             shuffle=True)
>>> a, b = next(iter(dataloader))
>>> trainloader_sampler1 = torch.utils.data.DataLoader(brain,
                                                   batch_size=64,
                                                   sampler = Brain_Large_Sampler(b),
                                                   shuffle=False)
>>> c, d = next(iter(trainloader_sampler1))

Methods