Last active
April 11, 2019 03:52
-
-
Save crawftv/dd01cdb4282f572b87f3e4e8ba3f9a44 to your computer and use it in GitHub Desktop.
Skopt Tutorial - Load & Transform Data
This file contains 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
from keras.datasets import mnist | |
(X_train, y_train), (X_test, y_test) = mnist.load_data() | |
#Scale the data to between 0 and 1 | |
X_train = X_train/ 255 | |
X_test = X_test/ 255 | |
#Flatten arrays from (28x28) to (784x1) | |
X_train = X_train.reshape(60000,784) | |
X_test = X_test.reshape(10000,784) | |
#Convert the y's to categorical to use with the softmax classifier | |
from keras.utils import np_utils | |
y_train = np_utils.to_categorical(y_train, 10) | |
y_test = np_utils.to_categorical(y_test, 10) | |
#Establish the input shape for our Networks. | |
input_shape= X_train[0].shape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment