Skip to content

Instantly share code, notes, and snippets.

@Merwanski
Created June 18, 2022 02:17
Show Gist options
  • Save Merwanski/ddbf79652a6813395aa46a2f4f20c558 to your computer and use it in GitHub Desktop.
Save Merwanski/ddbf79652a6813395aa46a2f4f20c558 to your computer and use it in GitHub Desktop.
import minst dataset from tensorflow
# import necessary packages
import tensorflow as tf
import tensorflow_datasets as tfds
# Construct a tf.data.Dataset
# Data loaded into ~/tensorflow_datasets/mnist
ds = tfds.load('mnist', split='train', shuffle_files=True)
# Build your input pipeline
ds=ds.shuffle(1024).batch(32).prefetch(tf.data.experimental.AUTOTUNE)
for example in ds.take(1):
image, label = example["image"], example["label"]
assert image.shape == (32, 28, 28, 1)
assert label.shape == (32,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment