API symbolsutils
Copy
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.
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?
