Question 1
Fill in the blanks to produce a CNN for classification!
from tensorflow import keras
from keras.layers import Input, Dense, Dropout, Flatten, ____2D, _________2D
#load the data
#define the network
conv1 = Conv2D(16, kernel_size=(3,3), activation=’______’, input_shape=X_train.shape[1:])
conv2 = ______(32, kernel_size=(3,3), activation=’relu’)
mpool = _________(pool_size=(2,2))
## MLP layers
flat = Flatten()
dense1 = Dense(128, _____________)
dense2 = Dense(num_classes, __________)
#compile and train
x_inputs = Input(shape=X_train.shape[1:])
x = conv1(_______)
x = ______(x)
x = ______(x)
x = flat(x)
x = dense1(x)
output_yhat = dense2(x)
model = keras.Model(inputs = _______, outputs = _______, name=”hello-world-cnn”)
Question 4
For an MNIST input image, how many parameters does a Conv2D layer require when being defined to produce 16 feature maps as output and a 3x3 neighborhood. How many parameters does a Dense layer with 16 outputs have? Compute the two parameter counts!