The first activity is the data preparation. To start, let's import all the required libraries. As we discussed earlier, we are going to use the MNIST database for the dataset of handwritten digits:
from __future__ import print_functionfrom matplotlib import pyplot as pltimport kerasfrom keras.datasets import mnist
mnist is the dataset that contains the handwritten digits database, so we need to import that, as follows:
from keras.models import Sequential
The preceding code imports the Sequential model type from Keras. This is simply a linear stack of neural network layers:
from keras.layers import Dense, Dropout, Flatten
Now, we need to import the core layers from Keras. These are the layers that are used in almost any ...