MNIST Digits With Keras

These are the parts that will make up the model.

Imports

The Sequential Model

The Keras Sequential Model is a stack of layers that will make up the neural network.

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
from keras.models import Sequential

The Dense Layers

The Keras Dense layer is a densely-connected layer within our neural network.

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
from keras.layers.core import Activation

Activation

The Activation represents the activation function for each layer (e.g. relu).

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
from keras.layers.core import Activation

Adam

To tune the model to the data we'll use the Adam optimizer

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
from keras.optimizers import Adam

Categorical Converter

Finally, since our problem is a classification problem (identify which of 10 digits an image represents) I'll import the Keras to_categorical function to enable classification of our data.

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
from keras.utils import np_utils

The MNIST dataset is made up of human-classified hand-written digits. Keras includes it as part of their installation so we can load it directly from keras.

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
from keras.datasets import mnist

We're going to use numpy to reshape the data.

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
import numpy

To make our output the same every time, I'll set the random seed to April 28, 2018 as a string of digits.

/home/athena/.virtualenvs/necromuralist.github.io/bin/python3: No module named virtualfish
numpy.random.seed(4282018)