MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / StreamingFilesDataset

Function StreamingFilesDataset

tensorflow/python/tpu/datasets.py:51–199  ·  view source on GitHub ↗

StreamingFilesDataset constructs a dataset to stream from workers (GCE VM). Because Cloud TPUs are allocated over the network, a Cloud TPU cannot read files local to your GCE VM. In order to train using files stored on your local VM (e.g. on local SSD for extreme performance), use the Streami

(files,
                          filetype=None,
                          file_reader_job=None,
                          worker_job=None,
                          num_epochs=None,
                          filename_shuffle_buffer_size=None,
                          num_parallel_reads=None,
                          batch_transfer_size=None,
                          sloppy=None)

Source from the content-addressed store, hash-verified

49
50
51def StreamingFilesDataset(files,
52 filetype=None,
53 file_reader_job=None,
54 worker_job=None,
55 num_epochs=None,
56 filename_shuffle_buffer_size=None,
57 num_parallel_reads=None,
58 batch_transfer_size=None,
59 sloppy=None):
60 """StreamingFilesDataset constructs a dataset to stream from workers (GCE VM).
61
62 Because Cloud TPUs are allocated over the network, a Cloud TPU cannot read
63 files local to your GCE VM. In order to train using files stored on your local
64 VM (e.g. on local SSD for extreme performance), use the StreamingFilesDataset
65 helper to generate a dataset to feed your Cloud TPU with files from your GCE
66 VM.
67
68 The resulting dataset may return an OutOfRangeError if there are no files
69 found as a result of the fileglob expansion.
70
71 Note: StreamingFilesDataset assumes that the session is using a
72 TPUClusterResolver and has therefore a worker and a coordinator job. File
73 loading will be done on the coordinator job.
74
75 Args:
76 files: A string glob to match files, or a `tf.data.Dataset` generating file
77 names.
78 filetype: A string (one of 'tfrecord', or 'textline') or a single-argument
79 TensorFlow function that when given a filename returns a dataset.
80 file_reader_job: An optional string that corresponds to the job that should
81 perform the file reads.
82 worker_job: An optional string that corresponds to the job that should
83 process the tensors (i.e. your GPU or TPU worker).
84 num_epochs: The number of epochs through the training set that should be
85 generated. By default, it will repeat infinitely.
86 filename_shuffle_buffer_size: An optional integer whose value controls the
87 shuffling of the file names. If you would like to read from the files in
88 the same order, set to 0 or False.
89 num_parallel_reads: An optional integer controlling the number of files to
90 read from concurrently. (Set to 1 for no parallelism.)
91 batch_transfer_size: An optional integer controlling the batching used to
92 amortize the remote function invocation overhead. Set to a very large
93 number to increase throughput. Set to a very small number to reduce memory
94 consumption. Set to False to skip batching.
95 sloppy: (Optional.) If `False`, read input data while maintaining a
96 deterministic order. (This may have significant performance impacts.)
97 sloppy defaults to: True.
98 Returns:
99 A `tf.data.Dataset` with an infinite stream of elements generated by a
100 parallel interleaving of the set of files matched (or generated) by `files`
101 with a type is the output of the dataset specified by `filetype`.
102
103 Raises:
104 ValueError: if any argument is not of the expected type.
105 """
106 if filetype is None:
107 filetype = 'tfrecord'
108

Callers

nothing calls this directly

Calls 12

string_handleMethod · 0.80
unbatchMethod · 0.80
deviceMethod · 0.45
list_filesMethod · 0.45
shuffleMethod · 0.45
applyMethod · 0.45
repeatMethod · 0.45
batchMethod · 0.45
prefetchMethod · 0.45
mapMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected