Modeling

  1. Firstly, let's initialize the random number generator to a constant seed value for reproducibility of results:
numpy.random.seed(0)
  1. Keras sequential layers are stacked so that every layer transfers its output to the next layer without defining additional data; let's import Sequential from the models:
# create sequential modelmodel = Sequential()
  1. To improve the efficiency and the convergence of the algorithm, we normalize the data based on the fact that the maximum pixel value is 255, so we divide all the pixels by 255 to obtain results between 0 and 1:
# normalize the datasetXTrain = XTrain / 255XTest = XTest / 255
  1. Exploring the data is an important aspect for choosing the right algorithm and getting the accuracy metric we ...

Get Keras Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.