The tf.data.Dataset object

A tf.data.Dataset object represents an input pipeline as a collection of elements accompanied by an ordered set of transformations that act on those elements.

Each element contains one or more tf.Tensor objects. For example, for an image classification problem, the tf.data.Dataset elements might be single training examples with a pair of tensors representing the image and its associated label.

There are several ways of creating a dataset object, depending on the data source.

Depending on the data position and format, the tf.data.Dataset class offers many static methods to use to create a dataset easily:

  • Tensors in memory: tf.data.Dataset.from_tensors or tf.data.Dataset.from_tensor_slices. In this case, the tensors ...

Get Hands-On Neural Networks with TensorFlow 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.