tf.data.Dataset is the central class provided by the tf.data API (refer to the documentation at https://www.tensorflow.org/api_docs/python/tf/data/Dataset). Instances of this class (which are simply called datasets) represent data sources, following the lazy list paradigm we just presented.
Datasets can be initialized in a multitude of ways, depending on how their content is initially stored (in files, NumPy arrays, tensors, and others). For example, a dataset can be based on a list of image files, as follows:
dataset = tf.data.Dataset.list_files("/path/to/dataset/*.png")
Datasets also have numerous methods they can apply to themselves in order to provide a transformed dataset. For example, the following function returns a new dataset instance with the file's contents properly transformed (that is, parsed) into homogeneously resized image tensors:
def parse_fn(filename):
img_bytes = tf.io.read_file(filename)
img = tf.io.decode_png(img_bytes, channels...