In this section, we will train our model with the same convolution neural network architecture that we used in Chapter 6, Improving the Image Classifier with CNN. Let's get started:
- We will start by importing the keras and sklearn libraries. We are importing Sequential, Conv2D, MaxPooling2D, Dense, Flatten, Dropouts, Adam, TensorBoard, and check_ouput from Keras. We have imported train_test_split from sklearn:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from subprocess import check_output
from sklearn.model_selection import train_test_split
- Next, we will build the following model:
cnn_model = tf.keras.Sequential()
cnn_model.add(tf.keras.layers.Conv2D(32,3, 3, input_shape = image_shape, activation='relu'))
cnn_model.add(tf.keras.layers.Conv2D(64, (3,3), activation='relu'))
cnn_model.add(tf.keras.layers.MaxPooling2D(pool_size = (2, 2)))
cnn_model.add(tf.keras.layers.Dropout(0.25))
cnn_model.add(tf.keras.layers...