tfds.as_numpy

Converts a tf.data.Dataset to an iterable of NumPy arrays.

tfds.as_numpy(
    dataset,
    graph=None
)

Defined in core/dataset_utils.py.

as_numpy converts a possibly nested structure of tf.data.Datasets and tf.Tensors to iterables of NumPy arrays and NumPy arrays, respectively.

Args:

  • dataset: a possibly nested structure of tf.data.Datasets and/or tf.Tensors.
  • graph: tf.Graph, optional, explicitly set the graph to use.

Returns:

A structure matching dataset where tf.data.Datasets are converted to generators of NumPy arrays and tf.Tensors are converted to NumPy arrays.