October 2018
Intermediate to advanced
472 pages
10h 57m
English
Now that you have an understanding of how convolution works, let's put it into use and build a CNN classifier on MNIST digits.
For this, import the Conv2D API from the layers module of Keras. You can do this with the following code:
from keras.layers import Conv2D
Since the convolution will be defined to accept images of shape 28*28*1, we need to reshape all the images to be of 28*28*1:
# reshape data X_train = X_train.reshape(-1,28,28,1)X_val = X_val.reshape(-1,28,28,1)X_test = X_test.reshape(-1,28,28,1)print('Train data shape:', X_train.shape)print('Val data shape:', X_val.shape)print('Test data shape:', X_test.shape)
The following is the output of the preceding code:
To build ...
Read now
Unlock full access