Classifying handwritten digits
In the previous section, we covered a lot of the theory around neural networks, which can be a little overwhelming if you are new to this topic. In this section, we will classify handwritten digits from the popular MNIST dataset, which has been constructed by Yann LeCun and colleagues and serves as a popular benchmark dataset for machine learning algorithms.
We will train two different networks on it:
- a multilayer perceptron using OpenCV
- a deep neural net using Keras
Loading the MNIST dataset
The easiest way to obtain the MNIST dataset is using Keras:
In [1]: from keras.datasets import mnist ... (X_train, y_train), (X_test, y_test) = mnist.load_data() Out[1]: Using TensorFlow backend. Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
This will download the data from the Amazon Cloud (might take a while depending on your internet connection) and automatically split the data into training and test sets.
Note
MNIST provides its own...