from keras.datasets import mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()
(X_train.shape, y_train.shape, X_test.shape, y_test.shape)
>> ((60000, 28, 28), (60000,), (10000, 28, 28), (10000,))
X_test = np.expand_dims(X_test,1)
X_train = np.expand_dims(X_train,1)
X_train.shape
>> (60000, 1, 28, 28)
y_train[:5]
>> array([5, 0, 4, 1, 9], dtype=uint8)
# hot encoding
y_train = onehot(y_train)
y_test = onehot(y_test)
y_train[:5]
array([[ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],
[ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.],
[ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]])
Last active
December 5, 2017 17:40
-
-
Save fabsta/c238b1bfd7a3d0077eb431d11383c298 to your computer and use it in GitHub Desktop.
Reading data #deeplearning #InputOutput
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment