The model
Now that you have a dataset of images and you know what you want to do (for instance, a classification), it's time to build your model!
We assume that you are working on a convolutional neural network, so you might even just use convolutional blocks, MaxPooling, and dense layers. But how to size them? How many layers should be used?
Let's do some tests with CIFAR-10, as MINST is too easy, and see what happens. We will not change the other parameters, but just play with these layers a bit.
We will also train for 5 epochs, so as to speed up training. This is not about getting the best neural network; it is about measuring the impact of some parameters.
Our starting point is a network with one convolutional layer, one MaxPooling layer, and one dense layer, shown as follows:
model = Sequential() model.add(Conv2D(8, (3, 3), input_shape=x_train.shape[1:], activation='relu')) model.add(MaxPooling2D()) model.add(Flatten()) model.add(Dense(units...