Skip to content

Instantly share code, notes, and snippets.

@rsepassi
Created February 22, 2019 22:53
Show Gist options
  • Save rsepassi/cc5d074dcac1dbb560ba2540cccd633c to your computer and use it in GitHub Desktop.
Save rsepassi/cc5d074dcac1dbb560ba2540cccd633c to your computer and use it in GitHub Desktop.
import tensorflow_datasets as tfds
# Download the dataset and create a tf.data.Dataset
ds, info = tfds.load("mnist", split="train", with_info=True)
# Access relevant metadata with DatasetInfo
print(info.splits["train"].num_examples)
print(info.features["label"].num_classes)
# Build your input pipeline
ds = ds.batch(128).repeat(10)
# And get NumPy arrays if you'd like
for ex in tfds.as_numpy(ds):
np_image, np_label = ex["image"], ex["label"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment