text: from matplotlib import pyplot
  from utils.mnist_reader import load_mnist
  from keras.preprocessing.image import ImageDataGenerator
  from keras.models import Sequential
  from keras.layers import Dense, Dropout, Activation, Flatten
  from keras.optimizers import Adam
  from keras.layers.normalization import BatchNormalization
  from keras.utils import np_utils
  from keras.layers import Conv2D, MaxPooling2D, ZeroPadding2D, GlobalAveragePooling2D
  from keras.layers.advanced_activations import LeakyReLU 
  
  # Load data and set it up for training
  X_train, y_train = load_mnist('data', kind='train')
  X_test, y_test = load_mnist('data', kind='test')
  X_train = X_train.reshape(X_train.shape[0], 64, 64, 1)
  X_test = X_test.reshape(X_test.shape[0], 64, 64, 1)
  X_train = X_train.astype('float32')
  X_test = X_test.astype('float32')
  X_train/=255
  X_test/=255
  number_of_classes = 26
  Y_train = np_utils.to_categorical(y_train, number_of_classes)
  Y_test = np_utils.to_categorical(y_test, number_of_classes)
  
  # Model
  model = Sequential()
  
  model.add(Conv2D(32, (5, 5), input_shape=(64, 64, 1), activation='relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.5))
  model.add(Conv2D(64, (3, 3), activation='relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.2))
  model.add(Conv2D(128, (1, 1), activation='relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.2))
  model.add(Flatten())
  model.add(Dense(128, activation='relu'))
  model.add(Dense(number_of_classes, activation='softmax'))
  
  model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
  
  gen = ImageDataGenerator(rotation_range=20, width_shift_range=0.2,
          height_shift_range=0.2,
          shear_range=0.2,
          zoom_range=0.2)
  
  test_gen = ImageDataGenerator()
  
  train_generator = gen.flow(X_train, Y_train, batch_size=32)
  test_generator = test_gen.flow(X_test, Y_test, batch_size=32)
  
  # Train it
  
  model.fit_generator(train_generator, steps_per_epoch=2549//32, epochs=80, 
                      validation_data=test_generator)
  
  score = model.evaluate(X_test, Y_test)
  print()
  print('Test accuracy: ', score[1])
  
  model.save_weights("chars74k_weights.h5")
  model.save('chars74k.h5')
  
  
  
  