import tempfilepath = os.path.join(tempfile.gettempdir(), "saved_data")# Save a datasetdataset = tf.data.Dataset.range(2)tf.data.experimental.save(dataset, path)new_dataset = tf.data.experimental.load(path)for elem in new_dataset: print(elem)tf.Tensor(0, shape=(), dtype=int64)tf.Tensor(1, shape=(), dtype=int64)
The saved dataset is saved in multiple file "shards". By default, the dataset
output is divided to shards in a round-robin fashion but custom sharding can
be specified via the shard_func function. For example, you can save the
dataset to using a single shard as follows:
Required. A directory to use for saving the dataset.
compression
Optional. The algorithm to use to compress data when writing
it. Supported options are GZIP and NONE. Defaults to NONE.
shard_func
Optional. A function to control the mapping of dataset elements
to file shards. The function is expected to map elements of the input
dataset to int64 shard IDs. If present, the function will be traced and
executed as graph computation.
checkpoint_args
Optional args for checkpointing which will be passed into
the tf.train.CheckpointManager. If checkpoint_args are not specified,
then checkpointing will not be performed. The save() implementation
creates a tf.train.Checkpoint object internally, so users should not
set the checkpoint argument in checkpoint_args.
Returns
An operation which when executed performs the save. When writing
checkpoints, returns None. The return value is useful in unit tests.
Raises
ValueError if checkpoint is passed into checkpoint_args.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-01-23 UTC."],[],[]]