To use this code you should have keras installed in your machine.
MNIST dataset for trainig purpose can be imported from keras itself or you may use EMNNIST dataset in '.mat' format which can be dowloaded from the like below:
#link for EMNIST : http://www.itl.nist.gov/iaui/vip/cs_links/EMNIST/matlab.zip
Model's weights are saved to HDF5 format. This is a grid format that is ideal for storing multi-dimensional arrays of numbers and for this you may need to install h5py first in your working environment.
If you are using Ubuntu you may use the following command to install h5py:
$ conda install h5py