Class RandomSampler

Inheritance Relationships

Base Type

Class Documentation

class RandomSampler : public mindspore::dataset::Sampler

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

Note

Samples the elements randomly.

Public Functions

explicit RandomSampler(bool replacement = false, int64_t num_samples = 0)

Constructor.

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

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

样例
/* creates a RandomSampler that will get 10 samples randomly */
std::string folder_path = "/path/to/image/folder";
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, std::make_shared<RandomSampler>(false, 10));
~RandomSampler() = default

Destructor.