Complete the code to add a convolutional layer with 32 filters and a 3x3 kernel.
model.add(Conv2D([1], kernel_size=(3, 3), activation='relu', input_shape=(28, 28, 1)))
The first convolutional layer commonly uses 32 filters to extract features from the input images.
Complete the code to add a max pooling layer with pool size 2x2.
model.add(MaxPooling2D(pool_size=[1]))Max pooling with a 2x2 window reduces the spatial size by half, helping reduce computation.
Fix the error in the code to flatten the output before the dense layer.
model.add([1]())Flatten layer converts 2D feature maps into 1D vectors for dense layers.
Fill both blanks to add a dropout layer with rate 0.5 and a dense output layer with 10 units.
model.add(Dropout([1])) model.add(Dense([2], activation='softmax'))
Dropout with 0.5 rate helps prevent overfitting. The output layer has 10 units for 10 classes.
Fill all three blanks to compile the model with Adam optimizer, categorical crossentropy loss, and accuracy metric.
model.compile(optimizer='[1]', loss='[2]', metrics=['[3]'])
Adam optimizer is popular for CNNs. Categorical crossentropy is used for multi-class classification. Accuracy measures performance.