Class SubsetRandomSampler

Inheritance Relationships

Base Type

Class Documentation

class SubsetRandomSampler : public mindspore::dataset::SubsetSampler

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

Note

Samples the elements randomly from a sequence of indices.

Public Functions

explicit SubsetRandomSampler(const std::vector<int64_t> &indices, int64_t num_samples = 0)

Constructor.

Parameters
  • indices[in] A vector sequence of indices.

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

Example
/* create a SubsetRandomSampler, will sample from the provided indices */
std::string folder_path = "/path/to/image/folder";
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, false, std::make_shared<SubsetRandomSampler>({2, 7}));
~SubsetRandomSampler() = default

Destructor.