Skip to content

Instantly share code, notes, and snippets.

@siakon89
Created March 29, 2020 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siakon89/0f9a43796e5ebd5f50e844a0dfb84e75 to your computer and use it in GitHub Desktop.
Save siakon89/0f9a43796e5ebd5f50e844a0dfb84e75 to your computer and use it in GitHub Desktop.
from tensorflow.keras.utils import to_categorical
# Normalize the images
train_images = train_images / 255.0
test_images = test_images / 255.0
# Reshape them for our CNN model
train_images = train_images.reshape(60000,28,28,1)
test_images = test_images.reshape(10000,28,28,1)
print(train_images.shape)
# Encode labels to one-hot
train_labels = to_categorical(train_labels)
test_labels = to_categorical(test_labels)
print(train_labels[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment