Catat tanggalnya! Google I / O mengembalikan 18-20 Mei Daftar sekarang


Converts a to an iterable of NumPy arrays.

Used in the notebooks

Used in the tutorials

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

Note that because TensorFlow has support for ragged tensors and NumPy has no equivalent representation, tf.RaggedTensors are left as-is for the user to deal with them (e.g. using to_list()). In TF 1 (i.e. graph mode), tf.RaggedTensors are returned as tf.ragged.RaggedTensorValues.


ds = tfds.load(name="mnist", split="train")
ds_numpy = tfds.as_numpy(ds)  # Convert `` to Python generator
for ex in ds_numpy:
  # `{'image': np.array(shape=(28, 28, 1)), 'labels': np.array(shape=())}`

dataset a possibly nested structure of and/or tf.Tensors.

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