TensorFlow 1 version View source on GitHub

Returns the single element in dataset as a nested structure of tensors.

This function enables you to use a in a stateless "tensor-in tensor-out" expression, without creating an iterator. This can be useful when your preprocessing transformations are expressed as a Dataset, and you want to use the transformation at serving time.

For example:

def preprocessing_fn(input_str):
  # ...
  return image, label

input_batch = ...  # input batch of BATCH_SIZE elements
dataset = (
           .map(preprocessing_fn, num_parallel_calls=BATCH_SIZE)

image_batch, label_batch =

dataset A object containing a single element.

A nested structure of tf.Tensor objects, corresponding to the single element of dataset.

TypeError if dataset is not a object. InvalidArgumentError (at runtime): if dataset does not contain exactly one element.