Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created March 2, 2018 14:16
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 NMZivkovic/f660ec8efa638f73bdca7d8b2995d3b9 to your computer and use it in GitHub Desktop.
Save NMZivkovic/f660ec8efa638f73bdca7d8b2995d3b9 to your computer and use it in GitHub Desktop.
from keras.datasets import mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()
rows, cols = X_train[0].shape[0], X_train[0].shape[1]
X_train = X_train.reshape(X_train.shape[0], rows, cols, 1)
X_test = X_test.reshape(X_test.shape[0], rows, cols, 1)
X_train = X_train.astype('float32')/255
X_test = X_test.astype('float32')/255
num_of_classes = len(set(y_train))
y_train = to_categorical(y_train, num_of_classes)
y_test = to_categorical(y_test, num_of_classes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment