TensorPlay
API symbolsutils
Copy
View MarkdownDownload .md

WeightedRandomSampler

class tensorplay.utils.data.WeightedRandomSampler(weights: Sequence[float], num_samples: int, replacement: bool = True, generator: Generator | None = None)[source]

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

Parameters:
  • weights (sequence) – a sequence 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.

  • generator (Generator) – Generator used in sampling.

Ask DeepWiki