The Keras framework provides built-in functions for training and testing the model. These are shown below. Training is performed on the set of training images. The labelled data set is used to drive back-propagation algorithms to adjust the weights to minimize the chosen cost function (in this case “sparse categorical cross-entropy”). An “accuracy” metric is chosen to assess quality of result. After five training epochs, the network accuracy of 99.1% is achieved on the test data set.