Template Function mindspore::dataset::RandomData
Defined in File datasets.h
Function Documentation
Function to create a RandomDataset.
- Parameters
total_rows – [in] Number of rows for the dataset to generate (default=0, number of rows is random).
schema – [in] SchemaObj to set column type, data type and data shape.
columns_list – [in] List of columns to be read (default={}, read all columns).
cache – [in] Tensor cache to use (default=nullptr which means no cache is used).
- Returns
Shared pointer to the RandomDataset.
Example/* Define MindData objects */ std::shared_ptr<SchemaObj> schema = Schema(); schema->add_column("column1", mindspore::DataType::kNumberTypeUInt8, {2}); schema->add_column("column2", mindspore::DataType::kNumberTypeUInt8, {1}); std::shared_ptr<Dataset> ds = RandomData(50, schema); /* Create iterator to read dataset */ std::shared_ptr<Iterator> iter = ds->CreateIterator(); std::unordered_map<std::string, mindspore::MSTensor> row; iter->GetNextRow(&row); /* Note: As we defined the schema before, each data dictionary owns keys "column1" and "column2" */ auto column1 = row["column1"];