|TensorFlow 1 version||View source on GitHub|
Dataset comprising lines from one or more text files.
tf.data.TextLineDataset( filenames, compression_type=None, buffer_size=None, num_parallel_reads=None )
Used in the notebooks
|Used in the guide||Used in the tutorials|
tf.data.TextLineDataset loads text from text files and creates a dataset
where each line of the files becomes an element of the dataset.
For example, suppose we have 2 files "text_lines0.txt" and "text_lines1.txt" with the following lines:
with open('/tmp/text_lines0.txt', 'w') as f:
with open('/tmp/text_lines1.txt', 'w') as f:
f.write('jack and jill\n')
We can construct a TextLineDataset from them as follows:
dataset = tf.data.TextLineDataset(['/tmp/text_lines0.txt',
The elements of the dataset are expected to be:
for element in dataset.as_numpy_iterator():