Class TFRecordDataset

Inheritance Relationships

Base Type

Class Documentation

class TFRecordDataset : public mindspore::dataset::Dataset

A source dataset for reading and parsing datasets stored on disk in TFData format.

Public Functions

TFRecordDataset(const std::vector<std::vector<char>> &dataset_files, const std::vector<char> &schema, const std::vector<std::vector<char>> &columns_list, int64_t num_samples, ShuffleMode shuffle, int32_t num_shards, int32_t shard_id, bool shard_equal_rows, const std::shared_ptr<DatasetCache> &cache)

Constructor of TFRecordDataset.

Parameters
  • dataset_files[in] List of files to be read to search for a pattern of files. The list will be sorted in a lexicographical order.

  • schema[in] Path to schema file.

  • columns_list[in] List of columns to be read (Default = {}, read all columns).

  • num_samples[in] The number of samples to be included in the dataset (Default = 0 means all samples). If num_samples is 0 and numRows(parsed from schema) does not exist, read the full dataset; If num_samples is 0 and numRows(parsed from schema) is greater than 0, read numRows rows; If both num_samples and numRows(parsed from schema) are greater than 0, read num_samples rows.

  • 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).

  • shard_equal_rows[in] Get equal rows for all shards (Default = False, number of rows of each shard may be not equal).

  • cache[in] Tensor cache to use (default=nullptr which means no cache is used).

TFRecordDataset(const std::vector<std::vector<char>> &dataset_files, const std::shared_ptr<SchemaObj> &schema, const std::vector<std::vector<char>> &columns_list, int64_t num_samples, ShuffleMode shuffle, int32_t num_shards, int32_t shard_id, bool shard_equal_rows, const std::shared_ptr<DatasetCache> &cache)

Constructor of TFRecordDataset.

Note

Parameter ‘schema’ is shared pointer to Schema object

Parameters
  • dataset_files[in] List of files to be read to search for a pattern of files. The list will be sorted in a lexicographical order.

  • 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).

  • num_samples[in] The number of samples to be included in the dataset (Default = 0 means all samples). If num_samples is 0 and numRows(parsed from schema) does not exist, read the full dataset; If num_samples is 0 and numRows(parsed from schema) is greater than 0, read numRows rows; If both num_samples and numRows(parsed from schema) are greater than 0, read num_samples rows.

  • 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).

  • shard_equal_rows[in] Get equal rows for all shards (Default = False, number of rows of each shard may be not equal).

  • cache[in] Tensor cache to use (default=nullptr which means no cache is used).

~TFRecordDataset() override = default

Destructor of TFRecordDataset.