text_plain_output_1.png
from keras.layers import Dense, Activation, Dropout

from keras.models import Sequential

from keras.optimizers import RMSprop

model = Sequential()
model.add(Dense(400, input_dim=784, activation='relu'))
model.add(Dropout(0.4))
model.add(Dense(200, activation='relu'))
model.add(Dropout(0.3))
model.add(Dense(300, activation='sigmoid'))
model.add(Dropout(0.2))
model.add(Dense(10, activation='softmax'))
model.compile(optimizer=RMSprop(), loss='categorical_crossentropy', metrics=['accuracy'])

epochs = 50
batch_size = 128
model.fit(X_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1)
score = model.evaluate(X_validate, y_validate, batch_size=32)

model2 = Sequential()
model2.add(Dense(400, input_dim=784, activation='relu'))
model.add(Dropout(0.4))
model2.add(Dense(200, activation='relu'))
model.add(Dropout(0.3))
model2.add(Dense(100, activation='relu'))
model.add(Dropout(0.2))
model2.add(Dense(50, activation='relu'))
model2.add(Dense(10, activation='softmax'))
model2.compile(optimizer=RMSprop(), loss='categorical_crossentropy', metrics=['accuracy'])

epochs = 20
batch_size = 128
model2.fit(X_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1)
score = model2.evaluate(X_validate, y_validate, batch_size=32)

model3 = Sequential()
model3.add(Dense(400, input_dim=784, activation='relu'))
model.add(Dropout(0.4))
model3.add(Dense(200, activation='sigmoid'))
model.add(Dropout(0.3))
model3.add(Dense(100, activation='sigmoid'))
model.add(Dropout(0.2))
model3.add(Dense(50, activation='sigmoid'))
model3.add(Dense(10, activation='softmax'))
model3.compile(optimizer=RMSprop(), loss='categorical_crossentropy', metrics=['accuracy'])

epochs = 20
batch_size = 128
model3.fit(X_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1)
score = model3.evaluate(X_validate, y_validate, batch_size=32)
print("Network's test score [loss, accuracy]: {0}".format(score))