Class WeightedRandomSampler

Inheritance Relationships

Base Type

Class Documentation

class WeightedRandomSampler : public mindspore::dataset::Sampler

A class to represent a Weighted Random Sampler in the data pipeline.

Note

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

Public Functions

explicit WeightedRandomSampler(std::vector<double> weights, int64_t num_samples = 0, bool replacement = true)

Constructor.

Parameters
  • weights[in] A vector sequence of weights, not necessarily summing up to 1.

  • num_samples[in] The number of samples to draw (default=0, return all samples).

  • replacement[in] If true, put the sample ID back for the next draw (default=true).

~WeightedRandomSampler() = default

Destructor.