C1_W3 - Convolution

Hello!
I have a question, could you help me?
Considering the code below:
"
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(32, (3,3), activation=‘relu’, input_shape=(28,28,1)),
tf.keras.layers.MaxPooling2D(2,2),

     tf.keras.layers.Flatten(),
     tf.keras.layers.Dense(128, activation='relu'),
     tf.keras.layers.Dense(10, activation='softmax')
 ])

"

  • I can say that the command “tf.keras.layers.Conv2D(32, (3,3), activation=‘relu’, input_shape=(28,28,1)),” creates 32 feature matrices and then reduces each one in half with the command “tf.keras.layers.MaxPooling2D(2,2),”?

Best regards

Yes, you can say that the command tf.keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(28,28,1)) creates 32 feature maps (or matrices). Each feature map is generated by applying 32 different filters, each of size 3x3, across the input image.

Following this, the command tf.keras.layers.MaxPooling2D(2,2) performs max pooling on these 32 feature maps. Max pooling with a pool size of 2x2 and a stride of 2 (defaults to pool_size) reduces the spatial dimensions of each feature map by half. This means that if the feature maps were of size (26, 26) before max pooling (since a 3x3 filter with ‘valid’ padding reduces the size from 28x28 to 26x26), they will be of size (13, 13) after max pooling.