brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler module

class brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler.BatchSampler(sampler, batch_size, drop_last)

Bases: object

Wraps another sampler to yield a mini-batch of indices.

Args:

sampler (Sampler): Base sampler. batch_size (int): Size of mini-batch. drop_last (bool): If True, the sampler will drop the last batch if

its size would be less than batch_size

Example:
>>> list(BatchSampler(range(10), batch_size=3, drop_last=False))
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
>>> list(BatchSampler(range(10), batch_size=3, drop_last=True))
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
class brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler.RandomSampler(data_source)

Bases: Sampler

Samples elements randomly, without replacement.

Arguments:

data_source (Dataset): dataset to sample from

class brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler.Sampler(data_source)

Bases: object

Base class for all Samplers.

Every Sampler subclass has to provide an __iter__ method, providing a way to iterate over indices of dataset elements, and a __len__ method that returns the length of the returned iterators.

class brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler.SequentialSampler(data_source)

Bases: Sampler

Samples elements sequentially, always in the same order.

Arguments:

data_source (Dataset): dataset to sample from

class brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler.SubsetRandomSampler(indices)

Bases: Sampler

Samples elements randomly from a given list of indices, without replacement.

Arguments:

indices (list): a list of indices

class brails.processors.foundation_classifier.csail_segmentation_tool.csail_seg.lib.utils.data.sampler.WeightedRandomSampler(weights, num_samples, replacement=True)

Bases: Sampler

Samples elements from [0,..,len(weights)-1] with given probabilities (weights).

Arguments:

weights (list) : a list of weights, not necessary summing up to one num_samples (int): number of samples to draw replacement (bool): if True, samples are drawn with replacement.

If not, they are drawn without replacement, which means that when a sample index is drawn for a row, it cannot be drawn again for that row.