Classifying MNIST

This time, let's introduce a 5 x 5 convolutional layer with 64 filters with ReLU activation, followed by a 2 x 2 max pooling layer with a stride of 2. This needs to be followed by a flattened layer and then a single hidden dense layer with 100 nodes, followed by the output softmax dense layer. As can be seen, the accuracy on the test dataset increased to 98.77% after training the model for 10 epochs:

import kerasfrom keras.models import Sequentialfrom keras.layers import Densefrom keras.utils import to_categoricalfrom keras.layers.convolutional import Conv2D # to add convolutional layersfrom keras.layers.convolutional import MaxPooling2D # to add pooling layersfrom keras.layers import Flatten # to flatten data for fully ...

Get Hands-On Image Processing with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.