Let's first look at how we will build the model from the input of MNIST images coming in batches:
input_shape = (28, 28)inputs = Input(input_shape)print(input_shape + (1, ))# add one more dimension for convolutionx = Reshape(input_shape + (1, ), input_shape=input_shape)(inputs)conv1 = Conv2D(14, kernel_size=4, activation='relu')(x)pool1 = MaxPooling2D(pool_size=(2, 2))(conv1)conv2 = Conv2D(7, kernel_size=4, activation='relu')(pool1)pool2 = MaxPooling2D(pool_size=(2, 2))(conv2)flatten = Flatten()(pool2)output = Dense(10, activation='sigmoid')(flatten)model = Model(inputs=inputs, outputs=output)
We start with the input_shape of (28, 28). This is used to define the input layer:
inputs = Input(input_shape)
Then we add another ...