cnn based deep learning classifier from scratch similar to any machine learning algorithmneural networks also require the input data to be certain shapesizeand type sobefore we reach the modeling stepthe first thing is to preprocess the data itself the following snippet gets the dataset and then performs one hot encoding of the labels remember there are classes to work with and hence we are dealing with multi-class classification problem in [ ]import keras from keras datasets import cifar num_classes (x_trainy_train)(x_testy_testcifar load_data(convert class vectors to binary class matrices y_train keras utils to_categorical(y_trainnum_classesy_test keras utils to_categorical(y_testnum_classesthe datasetif not already present locallywould be downloaded automatically the following are the shapes of the objects obtained in [ ]print('x_train shape:'x_train shapeprint(x_train shape[ ]'train samples'print(x_test shape[ ]'test samples'x_train shape( train samples test samples now that we have training and test datasets the next step is to build the cnn model since we have two dimensional images (the third dimension is the channel information)we will be using conv layers as discussed in the previous sectioncnns uses combination of convolutional layers and pooling layers followed by fully connected end to identify/classify the data the model architecture is built as follows in [ ]model sequential(model add(conv ( kernel_size=( )activation='relu'input_shape=input_shape)model add(conv ( ( )activation='relu')model add(maxpooling (pool_size=( ))model add(dropout( )model add(flatten()model add(dense( activation='relu')model add(dropout( )model add(dense(num_classesactivation='softmax')it starts off with convolutional layer with total of filters and activation function as the rectified linear unit (reluthe input shape resembles each image sizei (color image has three channels--rgbthis is followed by another convolutional layer and max-pooling layer finallywe have the fully connected dense layer since we have classes to choose fromthe final output layer has softmax activation