155
Split the dataset into training and testing subsets. Also, reshape the data to 28X28
images. Figure
4-45
shows the code to load and reshape images.
Figure
4-46
shows the code to display the images.
Figure 4-45. Code to load and reshape images
Figure 4-46. Code to display the images
Create a CNN model with Convolutions and MaxPool layers. Figure
4-47
shows the
code to create the neural network.
Chapter 4 autoenCoders
156
Compile the model using RMSprop as the optimizer and mean squared error for the
loss computation. The RMSprop optimizer is similar to the gradient descent algorithm
with momentum. Figure
4-48
shows the code to compile the model.
Figure 4-47. Code to create the neural network
Chapter 4 autoenCoders
157
Now, you can start training the model using the training dataset to validate the model
at every step. Choose 32 as the batchsize and 20 epochs. The training process outputs
the loss and accuracy as well as the validation loss and validation accuracy at each epoch.
Figure
4-49
shows the code to start training the model.
Do'stlaringiz bilan baham: