Create a gist now

Instantly share code, notes, and snippets.

from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.datasets import mnist
from keras.utils import np_utils
from keras.optimizers import SGD
model = Sequential()
(X_train, Y_train), (X_test, Y_test) = mnist.load_data()
X_train = X_train.reshape(-1, 28*28).astype('float32')/255
Y_train = np_utils.to_categorical(Y_train, 10)
X_test = X_test.reshape(-1, 28*28).astype('float32')/255
Y_test = np_utils.to_categorical(Y_test, 10)
model.add(Dense(output_dim=100, input_dim=784))
model.add(Dense(output_dim=10, input_dim=100))
model.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.01), metrics=['accuracy']), Y_train, nb_epoch=5, batch_size=100)
loss_and_metrics = model.evaluate(X_test, Y_test, batch_size=32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment