Samplers

Samplers are used during the training phase and are especially useful when your training data is not uniformly distributed among all of your classes.

class pywick.samplers.ImbalancedDatasetSampler(dataset, indices=None, num_samples=None)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Samples elements randomly from a given list of indices for imbalanced dataset

Parameters:
  • indices – (list, optional): a list of indices
  • num_samples – (int, optional): number of samples to draw
class pywick.samplers.MultiSampler(nb_samples, desired_samples, shuffle=False)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Samples elements more than once in a single pass through the data.

This allows the number of samples per epoch to be larger than the number of samples itself, which can be useful when training on 2D slices taken from 3D images, for instance.

gen_sample_array()[source]
class pywick.samplers.StratifiedSampler(class_vector, batch_size)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Stratified Sampling

Provides equal representation of target classes in each batch

Parameters:
  • class_vector – (torch tensor): a vector of class labels
  • batch_size – (int): size of the batch
gen_sample_array()[source]