Created
June 18, 2022 02:17
-
-
Save Merwanski/ddbf79652a6813395aa46a2f4f20c558 to your computer and use it in GitHub Desktop.
import minst dataset from tensorflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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