Function mindspore::dataset::Multi30k
Defined in File datasets.h
Function Documentation
Function to create a Multi30kDataset.
Note
The generated dataset has two columns [“text”, “translation”].
- Parameters
dataset_dir – [in] Path to the root directory that contains the dataset.
usage – [in] Part of dataset of MULTI30K, can be “train”, “test”, “valid” or “all” (default = “all”).
language_pair – [in] List containing text and translation language (default = {“en”, “de”}).
num_samples – [in] The number of samples to be included in the dataset (Default = 0, means all samples).
shuffle – [in] The mode for shuffling data every epoch (Default=ShuffleMode.kGlobal). Can be any of: ShuffleMode::kFalse - No shuffling is performed. ShuffleMode::kFiles - Shuffle files only. ShuffleMode::kGlobal - Shuffle both the files and samples.
num_shards – [in] Number of shards that the dataset should be divided into (Default = 1).
shard_id – [in] The shard ID within num_shards. This argument should be specified only when num_shards is also specified (Default = 0).
cache – [in] Tensor cache to use (default=nullptr, which means no cache is used).
- Returns
Shared pointer to the Multi30kDataset.
Example/* Define dataset path and MindData object */ std::string dataset_dir = "/path/to/multi30k_dataset_directory"; std::shared_ptr<Dataset> ds = Multi30k(dataset_dir, "all"); /* Create iterator to read dataset */ std::shared_ptr<Iterator> iter = ds->CreateIterator(); std::unordered_map<std::string, mindspore::MSTensor> row; iter->GetNextRow(&row); /* Note: In Multi30kdataset, each dictionary has keys "text" and "translation" */ auto text = row["text"];