Keras pooling layers
Keras implements a pooling operation as a layer that can be added to CNNs between other layers. In this exercise, you will construct a convolutional neural network similar to the one you have constructed before:
Convolution => Convolution => Flatten => Dense
However, you will also add a pooling layer. The architecture will add a single max-pooling layer between the convolutional layer and the dense layer with a pooling of 2x2:
Convolution => Max pooling => Convolution => Flatten => Dense
A Sequential model along with Dense, Conv2D, Flatten, and MaxPool2D objects are available in your workspace.
Bu egzersiz
Image Modeling with Keras
kursunun bir parçasıdırEgzersiz talimatları
- Add an input convolutional layer (15 units, kernel size of 2,
reluactivation). - Add a maximum pooling operation (pooling over windows of size 2x2).
- Add another convolution layer (5 units, kernel size of 2,
reluactivation). - Flatten the output of the second convolution and add a
Denselayer for output (3 categories,softmaxactivation).
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Add a convolutional layer
____(____(15, kernel_size=2, activation='relu',
input_shape=(img_rows, img_cols, 1)))
# Add a pooling operation
____
# Add another convolutional layer
____
# Flatten and feed to output layer
model.add(____)
model.add(____(3, activation='softmax'))
model.summary()