Last active
November 21, 2017 03:07
-
-
Save rish-16/7c745af7a403a60b52c8ffdf26408e1c to your computer and use it in GitHub Desktop.
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 numpy as np | |
| from keras.models import Sequential | |
| from keras.datasets import mnist | |
| from keras.layers import Dense | |
| from keras.utils import np_utils | |
| n_classes = 10 | |
| batch_size = 128 | |
| (X_train, y_train), (X_test, y_test) = mnist.load_data() | |
| X_train = X_train.reshape(60000, 784) | |
| X_test = X_test.reshape(10000, 784) | |
| y_train = np_utils.to_categorical(y_train, n_classes) | |
| y_test = np_utils.to_categorical(y_test, n_classes) | |
| model = Sequential() | |
| model.add(Dense(500, input_shape=[784,1]), activation='relu') | |
| model.add(Dense(500, activation='relu')) | |
| model.add(Dense(n_classes, activation='softax')) | |
| model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) | |
| model.fit(X_train, y_train, batch_size=batch_size, epochs=10) | |
| model.evaluate(X_test, y_test, batch_size=batch_size, verbose=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment