text_plain_output_1.png
from keras.layers import Dense, Dropout, Lambda, Flatten

from keras.models import Sequential

from keras.optimizers import Adam ,RMSprop

from keras.utils import np_utils

import matplotlib.pyplot as plt

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

train_file = pd.read_csv('../input/train.csv')
test_images = pd.read_csv('../input/test.csv')

train_images = train_file.ix[:, 1:].values.astype('float32')
train_labels = train_file.ix[:, 0].values.astype('int32')

train_images = train_images.reshape((42000, 28 * 28))

train_images = train_images / 255
test_images = test_images / 255
train_labels = np_utils.to_categorical(train_labels)
num_classes = train_labels.shape[1]

seed = 43
np.random.seed(seed)
model = Sequential()
model.add(Dense(64, activation='relu', input_dim=28 * 28))
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.15))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.15))
model.add(Dense(32, activation='relu'))
model.add(Dropout(0.15))
model.add(Dense(10, activation='softmax'))

model.compile(optimizer=RMSprop(lr=0.001), loss='categorical_crossentropy', metrics=['accuracy'])

history = model.fit(train_images, train_labels, validation_split=0.05, nb_epoch=25, batch_size=64)

history_dict = history.history
history_dict.keys()

plt.clf()
acc_values = history_dict['acc']
val_acc_values = history_dict['val_acc']
plt.plot(epochs, acc_values, 'bo')
plt.plot(epochs, val_acc_values, 'b+')
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.show()